Class: Grandstand::PagesController
- Inherits:
-
MainController
- Object
- ApplicationController
- MainController
- Grandstand::PagesController
- Defined in:
- app/controllers/grandstand/pages_controller.rb
Instance Method Summary collapse
Methods inherited from MainController
Instance Method Details
#create ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'app/controllers/grandstand/pages_controller.rb', line 5 def create @page = Grandstand::Page.new(params[:page]) if @page.save flash[:success] = "#{@page.name} was successfully added" redirect_to grandstand_page_path(@page) else flash[:error] = 'There was a problem creating this page' render :new end end |
#destroy ⇒ Object
16 17 18 19 20 |
# File 'app/controllers/grandstand/pages_controller.rb', line 16 def destroy @page.destroy flash[:delete] = 'Your page has been deleted' redirect_to grandstand_pages_path end |
#index ⇒ Object
22 23 24 |
# File 'app/controllers/grandstand/pages_controller.rb', line 22 def index @pages = Grandstand::Page.where(:parent_id => nil).all end |
#new ⇒ Object
26 27 28 29 |
# File 'app/controllers/grandstand/pages_controller.rb', line 26 def new @page = Grandstand::Page.new build_page_sections end |
#reorder ⇒ Object
31 32 33 34 35 36 |
# File 'app/controllers/grandstand/pages_controller.rb', line 31 def reorder params[:pages].each_with_index do |page_id, index| Grandstand::Page.update(page_id, :position => index + 1) end if params[:pages] render :json => {:status => :ok} end |
#update ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/grandstand/pages_controller.rb', line 38 def update if @page.update_attributes(params[:page]) flash[:success] = "#{@page.name} was successfully saved" request.xhr? ? render(:json => {:status => :ok}) : redirect_to(grandstand_page_path(@page)) else flash[:error] = 'There was a problem saving this page' render :edit end end |