Sha256: 2749bf348b35e8ada9c2196053226127e08a9121432419769a705795d9c1a7e0

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

module Locomotive
  module Api
    class BaseController < ApplicationController

      include Locomotive::Routing::SiteDispatcher
      include Locomotive::ActionController::LocaleHelpers

      skip_before_filter :verify_authenticity_token

      before_filter :require_account

      before_filter :require_site

      before_filter :set_locale

      before_filter :set_current_thread_variables

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

      respond_to :json, :xml

      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

      def set_locale
        ::Mongoid::Fields::I18n.locale = params[:locale] || current_site.default_locale
        ::I18n.locale = ::Mongoid::Fields::I18n.locale

        self.setup_i18n_fallbacks
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
locomotive_cms-2.0.0.rc11 app/controllers/locomotive/api/base_controller.rb
locomotive_cms-2.0.0.rc10 app/controllers/locomotive/api/base_controller.rb
locomotive_cms-2.0.0.rc9 app/controllers/locomotive/api/base_controller.rb
locomotive_cms-2.0.0.rc8 app/controllers/locomotive/api/base_controller.rb