Sha256: 7de730f77bb7142e0bb40cdb2d0e335d7d2fff8542a5f8d81ff7af75d82c7e1a
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
module SimplePages def self.included(base) base.send :include, InstanceMethods end module InstanceMethods def show if page_action.present? && respond_to?(page_action) executes_page_action else render_page_template end end protected def page_action @page_action ||= page_permalink params[:id] end def executes_page_action send page_action if page_action != "show" render page_template_path rescue ActionView::MissingTemplate render 'show' end def render_page_template render page_template_path rescue ActionView::MissingTemplate render 'not_found', :status => 404 end def page_template_path [controller_name, page_locale, page_action].compact * "/" end def page_locale return I18n.locale = params[:locale] if params[:locale] return I18n.locale if I18n.locale != I18n.default_locale end def page_permalink(string) URI.unescape(string || "show").parameterize.underscore end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simple_pages-0.1.1 | lib/simple_pages.rb |