Sha256: 8197118f47faa7b142474070fecf9eb18ae46f21f1a8faa011d0f6cdca3d58d4
Contents?: true
Size: 1.45 KB
Versions: 23
Compression:
Stored size: 1.45 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 # =================== # = 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
23 entries across 23 versions & 1 rubygems