Class: Comfy::Admin::Cms::LayoutsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/comfy/admin/cms/layouts_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @layout.save!
  flash[:success] = I18n.t('comfy.admin.cms.layouts.created')
  redirect_to :action => :edit, :id => @layout
rescue ActiveRecord::RecordInvalid
  flash.now[:danger] = I18n.t('comfy.admin.cms.layouts.creation_failure')
  render :action => :new
end

#destroyObject



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

def destroy
  @layout.destroy
  flash[:success] = I18n.t('comfy.admin.cms.layouts.deleted')
  redirect_to :action => :index
end

#editObject



16
17
18
# File 'app/controllers/comfy/admin/cms/layouts_controller.rb', line 16

def edit
  render
end

#indexObject



7
8
9
10
# File 'app/controllers/comfy/admin/cms/layouts_controller.rb', line 7

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

#newObject



12
13
14
# File 'app/controllers/comfy/admin/cms/layouts_controller.rb', line 12

def new
  render
end

#reorderObject



44
45
46
47
48
49
# File 'app/controllers/comfy/admin/cms/layouts_controller.rb', line 44

def reorder
  (params[:comfy_cms_layout] || []).each_with_index do |id, index|
    ::Comfy::Cms::Layout.where(:id => id).update_all(:position => index)
  end
  render :nothing => true
end

#updateObject



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

def update
  @layout.update_attributes!(layout_params)
  flash[:success] = I18n.t('comfy.admin.cms.layouts.updated')
  redirect_to :action => :edit, :id => @layout
rescue ActiveRecord::RecordInvalid
  flash.now[:danger] = I18n.t('comfy.admin.cms.layouts.update_failure')
  render :action => :edit
end