Class: PagesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/pages_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @page = Page.new page_params
  if @page.save
    #TODO: set flash message?
    redirect_to edit_page_url(@page.id)
  else
    render 'new'
  end
end

#destroyObject



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

def destroy
  @page.destroy
  redirect_to admin_pages_url
end

#editObject



13
14
15
# File 'app/controllers/pages_controller.rb', line 13

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

#indexObject



5
6
7
# File 'app/controllers/pages_controller.rb', line 5

def index
  @pages = Page.ordered
end

#newObject



9
10
11
# File 'app/controllers/pages_controller.rb', line 9

def new
  @page = Page.new
end

#updateObject



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

def update
  @page = Page.find params[:id]
  if @page.update(page_params)
    #TODO: set flash message?
    redirect_to edit_page_url(@page.id)
  else
    render 'edit'
  end
end