Class: GacoCms::Admin::PagesController

Inherits:
BaseController show all
Defined in:
app/controllers/gaco_cms/admin/pages_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#upload_file

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
# File 'app/controllers/gaco_cms/admin/pages_controller.rb', line 18

def create
  page = @page_type.pages.new(page_params)
  if page.save
    redirect_to url_for(action: :edit, id: page), notice: 'Page created'
  else
    render inline: page.errors.full_messages.join(', ')
  end
end

#destroyObject



37
38
39
40
# File 'app/controllers/gaco_cms/admin/pages_controller.rb', line 37

def destroy
  @page.destroy!
  redirect_to url_for(action: :index), notice: 'Page destroyed'
end

#editObject



27
# File 'app/controllers/gaco_cms/admin/pages_controller.rb', line 27

def edit; end

#indexObject



10
11
12
# File 'app/controllers/gaco_cms/admin/pages_controller.rb', line 10

def index
  @pages = @page_type.pages.title_ordered
end

#newObject



14
15
16
# File 'app/controllers/gaco_cms/admin/pages_controller.rb', line 14

def new
  @page = @page_type.pages.new
end

#updateObject



29
30
31
32
33
34
35
# File 'app/controllers/gaco_cms/admin/pages_controller.rb', line 29

def update
  if @page.update(page_params)
    render inline: ''
  else
    render inline: @page.errors.full_messages.join(', ')
  end
end