Class: Admin::PagesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/pages/templates/admin_pages_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
# File 'lib/generators/pages/templates/admin_pages_controller.rb', line 20

def create
  @page = Page.new(params[:page])

  if @page.save
    redirect_to(pages_path, :notice => 'Page was successfully created.')
  else
    render :action => "new"
  end
end

#destroyObject



40
41
42
43
44
45
# File 'lib/generators/pages/templates/admin_pages_controller.rb', line 40

def destroy
  @page = Page.find(params[:id])
  @page.destroy

  redirect_to(pages_path, :notice => 'Page was successfully removed.')
end

#editObject



16
17
18
# File 'lib/generators/pages/templates/admin_pages_controller.rb', line 16

def edit
  @page = Page.find(params[:id])
end

#indexObject



4
5
6
# File 'lib/generators/pages/templates/admin_pages_controller.rb', line 4

def index
  @pages = Page.order('updated_at desc')
end

#newObject



12
13
14
# File 'lib/generators/pages/templates/admin_pages_controller.rb', line 12

def new
  @page = Page.new
end

#showObject



8
9
10
# File 'lib/generators/pages/templates/admin_pages_controller.rb', line 8

def show
  @page = Page.find(params[:id])
end

#updateObject



30
31
32
33
34
35
36
37
38
# File 'lib/generators/pages/templates/admin_pages_controller.rb', line 30

def update
  @page = Page.find(params[:id])

  if @page.update_attributes(params[:page])
    redirect_to(pages_path, :notice => 'Page was successfully updated.')
  else
    render :action => "edit"
  end
end