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

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

Instance Method Summary collapse

Methods included from ReorderAction

#reorder

Instance Method Details

#createObject



25
26
27
28
29
30
31
32
# File 'app/controllers/comfy/admin/cms/layouts_controller.rb', line 25

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



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

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

#editObject



21
22
23
# File 'app/controllers/comfy/admin/cms/layouts_controller.rb', line 21

def edit
  render
end

#indexObject



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

def index
  return redirect_to action: :new if @site.layouts.count.zero?
  @layouts = @site.layouts.roots.order(:position)
end

#newObject



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

def new
  render
end

#updateObject



34
35
36
37
38
39
40
41
# File 'app/controllers/comfy/admin/cms/layouts_controller.rb', line 34

def update
  @layout.update!(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