Class: PagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- PagesController
- Defined in:
- app/controllers/pages_controller.rb
Instance Method Summary collapse
-
#home ⇒ Object
This action is usually accessed with the root path, normally ‘/’.
-
#show ⇒ Object
This action can be accessed normally, or as nested pages.
Instance Method Details
#home ⇒ Object
This action is usually accessed with the root path, normally ‘/’
4 5 6 |
# File 'app/controllers/pages_controller.rb', line 4 def home error_404 unless (@page = Page.where(:link_url => '/').first).present? end |
#show ⇒ Object
This action can be accessed normally, or as nested pages. Assuming a page named “mission” that is a child of “about”, you can access the pages with the following URLs:
GET /pages/about
GET /about
GET /pages/mission
GET /about/mission
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/pages_controller.rb', line 18 def show @page = Page.find("#{params[:path]}/#{params[:id]}".split('/').last) if @page.try(:live?) || (refinery_user? && current_user..include?("refinery_pages")) # if the admin wants this to be a "placeholder" page which goes to its first child, go to that instead. if @page.skip_to_first_child && (first_live_child = @page.children.order('lft ASC').live.first).present? redirect_to first_live_child.url and return elsif @page.link_url.present? redirect_to @page.link_url and return end else error_404 end end |