Class: Nuntius::Admin::LayoutsController

Inherits:
Nuntius::ApplicationAdminController show all
Defined in:
app/controllers/nuntius/admin/layouts_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



17
18
19
20
21
# File 'app/controllers/nuntius/admin/layouts_controller.rb', line 17

def create
  @layout = Nuntius::Layout.new(layout_params)
  @layout.save
  respond_with :admin, @layout
end

#destroyObject



42
43
44
45
46
# File 'app/controllers/nuntius/admin/layouts_controller.rb', line 42

def destroy
  @layout = Nuntius::Layout.visible.find(params[:id])
  @layout.destroy
  respond_with @layout
end

#editObject



23
24
25
# File 'app/controllers/nuntius/admin/layouts_controller.rb', line 23

def edit
  @layout = Nuntius::Layout.visible.find(params[:id])
end

#indexObject



8
9
10
# File 'app/controllers/nuntius/admin/layouts_controller.rb', line 8

def index
  @layouts = Nuntius::Layout.visible.order(:name)
end

#newObject



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

def new
  @layout = Nuntius::Layout.new
  render :edit
end

#showObject



27
28
29
# File 'app/controllers/nuntius/admin/layouts_controller.rb', line 27

def show
  redirect_to :edit_admin_layout, status: :see_other
end

#updateObject



31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/nuntius/admin/layouts_controller.rb', line 31

def update
  @layout = Nuntius::Layout.visible.find(params[:id])
  @layout.update(layout_params)
  if params[:layout][:attachments].present?
    params[:layout][:attachments].each do |attachment|
      @layout.attachments.attach(attachment)
    end
  end
  respond_with :admin, @layout
end