Sha256: a8fcafbcf9ed24e0e6f667461c848d90184d49e99e5f8a8ff97f02814a2a0625

Contents?: true

Size: 1.46 KB

Versions: 17

Compression:

Stored size: 1.46 KB

Contents

module Locomotive
  class BaseController < ApplicationController

    include Locomotive::Routing::SiteDispatcher
    include Locomotive::ActionController::LocaleHelpers
    include Locomotive::ActionController::SectionHelpers
    include Locomotive::ActionController::UrlHelpers

    layout '/locomotive/layouts/application'

    before_filter :require_account

    before_filter :require_site

    before_filter :validate_site_membership

    load_and_authorize_resource

    before_filter :set_back_office_locale

    before_filter :set_current_content_locale

    before_filter :set_current_thread_variables

    helper_method :sections, :current_ability

    helper Locomotive::BaseHelper, Locomotive::ContentTypesHelper

    self.responder = Locomotive::ActionController::Responder # custom responder

    respond_to :html

    rescue_from CanCan::AccessDenied do |exception|
      ::Locomotive.log "[CanCan::AccessDenied] #{exception.inspect}"

      if request.xhr?
        render :json => { :error => exception.message }
      else
        flash[:alert] = exception.message

        redirect_to pages_url
      end
    end

    protected

    def set_current_thread_variables
      Thread.current[:account]  = current_locomotive_account
      Thread.current[:site]     = current_site
    end

    def current_ability
      @current_ability ||= Ability.new(current_locomotive_account, current_site)
    end

    def require_account
      authenticate_locomotive_account!
    end

  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
locomotive_cms-2.0.3 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.0.2 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.0.1 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.0.0 app/controllers/locomotive/base_controller.rb
tribeca_cms-0.1.1 app/controllers/locomotive/base_controller.rb
tribeca_cms-2.0.0.rc12 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.0.0.rc12 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.0.0.rc11 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.0.0.rc10 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.0.0.rc9 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.0.0.rc8 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.0.0.rc7 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.0.0.rc6 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.0.0.rc5 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.0.0.rc4 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.0.0.rc2 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.0.0.rc1 app/controllers/locomotive/base_controller.rb