Class: PagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- PagesController
- Defined in:
- app/controllers/pages_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #order ⇒ Object
- #show ⇒ Object
- #translate ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/pages_controller.rb', line 61 def create @page = Page.new(params[:page]) @page.save! flash[:notice] = 'Page was successfully created.' redirect_to(@page) rescue ActiveRecord::RecordInvalid flash.now[:error] = "There was a problem creating the page" render :action => "new" end |
#destroy ⇒ Object
80 81 82 83 |
# File 'app/controllers/pages_controller.rb', line 80 def destroy @page.destroy redirect_to(pages_path) end |
#edit ⇒ Object
57 58 59 |
# File 'app/controllers/pages_controller.rb', line 57 def edit @page_title = "Edit CCLS Page #{@page.title(session[:locale])}" end |
#index ⇒ Object
46 47 48 49 50 |
# File 'app/controllers/pages_controller.rb', line 46 def index @page_title = "CCLS Pages" params[:parent_id] = nil if params[:parent_id].blank? @pages = Page.all(:conditions => { :parent_id => params[:parent_id] }) end |
#new ⇒ Object
52 53 54 55 |
# File 'app/controllers/pages_controller.rb', line 52 def new @page_title = "Create New CCLS Page" @page = Page.new(:parent_id => params[:parent_id]) end |
#order ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'app/controllers/pages_controller.rb', line 28 def order # params[:pages].reverse.each { |id| Page.find(id).move_to_top } # this doesn't even check for parents or anything # making it faster, but potentially error prone. params[:pages].each_with_index { |id,index| Page.find(id).update_attribute(:position, index+1 ) } redirect_to pages_path(:parent_id=>params[:parent_id]) end |
#show ⇒ Object
43 44 |
# File 'app/controllers/pages_controller.rb', line 43 def show end |
#translate ⇒ Object
37 38 39 40 41 |
# File 'app/controllers/pages_controller.rb', line 37 def translate respond_to do |format| format.js {} end end |
#update ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'app/controllers/pages_controller.rb', line 71 def update @page.update_attributes!(params[:page]) flash[:notice] = 'Page was successfully updated.' redirect_to(@page) rescue ActiveRecord::RecordInvalid flash.now[:error] = "There was a problem updating the page." render :action => "edit" end |