Class: Admin::SectionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/admin/sections_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#fresh_when, #redirect_back_or_default, #redirect_referrer_or_default, #render_403, #render_404, #render_optional_error_file, #require_user, #set_active_menu, #set_locale, #set_seo_meta, #store_location, #unread_notify_count

Instance Method Details

#createObject


19
20
21
22
23
24
25
26
27
# File 'app/controllers/admin/sections_controller.rb', line 19

def create
  @section = Section.new(params[:section].permit!)

  if @section.save
    redirect_to(admin_sections_path, notice: 'Section was successfully created.')
  else
    render action: 'new'
  end
end

#destroyObject


39
40
41
42
43
44
# File 'app/controllers/admin/sections_controller.rb', line 39

def destroy
  @section = Section.find(params[:id])
  @section.destroy

  redirect_to(admin_sections_url)
end

#editObject


15
16
17
# File 'app/controllers/admin/sections_controller.rb', line 15

def edit
  @section = Section.find(params[:id])
end

#indexObject


3
4
5
# File 'app/controllers/admin/sections_controller.rb', line 3

def index
  @sections = Section.all
end

#newObject


11
12
13
# File 'app/controllers/admin/sections_controller.rb', line 11

def new
  @section = Section.new
end

#showObject


7
8
9
# File 'app/controllers/admin/sections_controller.rb', line 7

def show
  @section = Section.find(params[:id])
end

#updateObject


29
30
31
32
33
34
35
36
37
# File 'app/controllers/admin/sections_controller.rb', line 29

def update
  @section = Section.find(params[:id])

  if @section.update_attributes(params[:section].permit!)
    redirect_to(admin_sections_path, notice: 'Section was successfully updated.')
  else
    render action: 'edit'
  end
end