Class: Dust::PagesController

Inherits:
AuthenticationController show all
Defined in:
app/controllers/dust/pages_controller.rb

Instance Method Summary collapse

Methods inherited from AuthenticationController

#not_authenticated, #permission_denied, #try_return_to_previous_page

Instance Method Details

#createObject



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

def create
  @page = Dust::Page.new_with_menu_item(params[:dust_page])
  @builder = Dust::Builder::Page.new(:page => @page, :sections => params[:sections])

  if @builder.save
    flash[:notice] = "Successfully created page."
    redirect_to front_end_page_path(@page.filename)
  else
    render :action => 'new', :layout => 'cms'
  end
end

#destroyObject



44
45
46
47
48
49
# File 'app/controllers/dust/pages_controller.rb', line 44

def destroy
  @page = Dust::Page.find(params[:id])
  @page.destroy
  flash[:notice] = "Successfully destroyed page."
  redirect_to dust_pages_url
end

#editObject



28
29
30
# File 'app/controllers/dust/pages_controller.rb', line 28

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

#indexObject



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

def index
  @pages = Dust::Page.page(params[:search], params[:page]) 
end

#newObject



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

def new
  @page = Dust::Page.new_with_menu_item
end

#updateObject



32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/dust/pages_controller.rb', line 32

def update
  @page = Dust::Page.find(params[:id])
  @builder = Dust::Builder::Page.new(:page => @page, :sections => params[:sections], :attrs => params[:dust_page])

  if @builder.update
    flash[:notice] = "Successfully updated page."
    redirect_to front_end_page_path(@page.filename)
  else
    render :action => 'edit'
  end
end