Class: Storytime::PagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Storytime::PagesController
- Defined in:
- app/controllers/storytime/pages_controller.rb
Direct Known Subclasses
Instance Method Summary collapse
Methods inherited from ApplicationController
#authenticate_user!, #current_user, #setup, #user_signed_in?
Methods included from Concerns::CurrentSite
Methods included from Concerns::ControllerContentFor
#content_for, #content_for?, #view_context
Instance Method Details
#show ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/storytime/pages_controller.rb', line 7 def show if params[:preview].nil? && params[:id].present? && !@page.nil? && params[:id] != @page.slug return redirect_to @page, :status => :moved_permanently end #allow overriding in the host app slug = @page.nil? ? ActionController::Base.helpers.sanitize(params[:id]) : @page.slug potential_templates = [ "storytime/#{@current_storytime_site.custom_view_path}/pages/#{slug}", "storytime/#{@current_storytime_site.custom_view_path}/pages/show", "storytime/pages/#{slug}", "storytime/pages/show", ] potential_templates.each do |template| # The /show fallbacks dereference @page, so skip them when no page was loaded. next if @page.nil? && template.end_with?("/show") if lookup_context.template_exists?(template) render template return end end raise ActionController::RoutingError, "No page found for #{params[:id].inspect}" end |