Class: Pagificate::PagesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

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

  respond_to do |format|
    if @page.save
      format.html { redirect_to pages_path, :notice => 'Page created successfully.' }
    else
      flash[:error] = 'Page could not be created.'
      format.html { render :action => :new }
    end
  end
end

#destroyObject



51
52
53
54
55
56
57
# File 'app/controllers/pagificate/pages_controller.rb', line 51

def destroy
  @page.destroy

  respond_to do |format|
    format.html { redirect_to pages_path, :notice => 'Page deleted.'}
  end
end

#editObject



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

def edit
end

#indexObject



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

def index
  @published_pages   = Page.where('pages.published = ?', true)
  @unpublished_pages = Page.where('pages.published = ?', false)
end

#newObject



20
21
22
# File 'app/controllers/pagificate/pages_controller.rb', line 20

def new
  @page = Page.new
end

#showObject



14
15
16
17
18
# File 'app/controllers/pagificate/pages_controller.rb', line 14

def show
  page = Page.find_by_permalink params[:id]
  page.published? ? @page = page : redirect_to('/', :notice => 'No such page exists')
  render :layout => false unless @page.use_site_layout?
end

#updateObject



40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/pagificate/pages_controller.rb', line 40

def update
  respond_to do |format|
    if @page.update_attributes(params[:page])
      format.html { redirect_to pages_path, :notice => 'Page updated.'}
    else
      flash[:error] = 'Page could not be updated.'
      format.html { render :action => :edit }
    end
  end
end