Class: CmsAdmin::LayoutsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/cms_admin/layouts_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
# File 'app/controllers/cms_admin/layouts_controller.rb', line 20

def create
  @cms_layout.save!
  flash[:notice] = 'Layout created'
  redirect_to :action => :index
rescue ActiveRecord::RecordInvalid
  flash.now[:error] = 'Failed to create layout'
  render :action => :new
end

#destroyObject



38
39
40
41
42
# File 'app/controllers/cms_admin/layouts_controller.rb', line 38

def destroy
  @cms_layout.destroy
  flash[:notice] = 'Layout deleted'
  redirect_to :action => :index
end

#editObject



16
17
18
# File 'app/controllers/cms_admin/layouts_controller.rb', line 16

def edit
  render
end

#indexObject



7
8
9
10
# File 'app/controllers/cms_admin/layouts_controller.rb', line 7

def index
  return redirect_to :action => :new if @cms_site.cms_layouts.count == 0
  @cms_layouts = @cms_site.cms_layouts.roots
end

#newObject



12
13
14
# File 'app/controllers/cms_admin/layouts_controller.rb', line 12

def new
  render
end

#updateObject



29
30
31
32
33
34
35
36
# File 'app/controllers/cms_admin/layouts_controller.rb', line 29

def update
  @cms_layout.update_attributes!(params[:cms_layout])
  flash[:notice] = 'Layout updated'
  redirect_to :action => :index
rescue ActiveRecord::RecordInvalid
  flash.now[:error] = 'Failed to update layout'
  render :action => :edit
end