Sha256: 1da9291eeaaae8cac6eb88744871e6c5b6af571839cdbab360bf09ed4c9d0a86
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
class Site::SiteController < ApplicationController include Pageable rescue_from ActiveRecord::RecordNotFound, :with => :render_404 authorize :scope => "site", :resourceful => false prepend_before_filter(:set_locale) if Fullstack::Cms.localized? # ========= # = Pages = # ========= page :home, "/" do end # =========== # = Helpers = # =========== helper_method :current_locale helper_method :home_page? protected def current_locale I18n.locale.to_s end def home_page? action_name == "home" end # =================== # = Private Methods = # =================== private def set_locale I18n.locale = "#{params[:locale]}".to_sym if params[:locale] render_404 if I18n.locale.nil? || !I18n.available_locales.include?(I18n.locale.to_sym) end def instantiate_resource_by_slug!(resource) res = resource.find_by_slug!(params[:slug]) instance_variable_set("@#{resource.name.underscore}", res) @object = res res end alias :resource_by_slug! :instantiate_resource_by_slug! def instantiate_resource_by_slug_and_locale!(resource) res = resource.find_by_slug_and_locale!(params[:slug], current_locale) instance_variable_set("@#{resource.name.underscore}", res) @object = res res end alias :resource_by_slug_and_locale! :instantiate_resource_by_slug_and_locale! def render_404 render :file => Rails.root.join("public", "404.html"), :layout => false, :status => :not_found end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fullstack-cms-0.2.24 | lib/generators/fullstack/cms/templates/rails/app/controllers/site/site_controller.rb |