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



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

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

#destroyObject



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

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

#editObject



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

def edit
  render
end

#indexObject



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

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

#newObject



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

def new
  render
end

#updateObject



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

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