2012-01-23 08:05:50 +00:00
|
|
|
module Locomotive
|
|
|
|
module Api
|
|
|
|
class BaseController < ApplicationController
|
|
|
|
|
|
|
|
include Locomotive::Routing::SiteDispatcher
|
|
|
|
include Locomotive::ActionController::LocaleHelpers
|
|
|
|
|
2012-02-20 15:16:59 +00:00
|
|
|
skip_before_filter :verify_authenticity_token
|
|
|
|
|
|
|
|
skip_load_and_authorize_resource
|
|
|
|
|
2012-01-23 08:05:50 +00:00
|
|
|
before_filter :require_account
|
|
|
|
|
|
|
|
before_filter :require_site
|
|
|
|
|
2012-01-27 01:27:26 +00:00
|
|
|
before_filter :set_locale
|
|
|
|
|
2012-01-23 08:05:50 +00:00
|
|
|
# before_filter :validate_site_membership
|
|
|
|
|
|
|
|
self.responder = Locomotive::ActionController::Responder # custom responder
|
|
|
|
|
|
|
|
respond_to :json, :xml
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def current_ability
|
|
|
|
@current_ability ||= Ability.new(current_locomotive_account, current_site)
|
|
|
|
end
|
|
|
|
|
|
|
|
def require_account
|
|
|
|
authenticate_locomotive_account!
|
|
|
|
end
|
|
|
|
|
2012-01-27 01:27:26 +00:00
|
|
|
def set_locale
|
|
|
|
::Mongoid::Fields::I18n.locale = params[:locale] || current_site.default_locale
|
|
|
|
::I18n.locale = ::Mongoid::Fields::I18n.locale
|
|
|
|
|
|
|
|
self.setup_i18n_fallbacks
|
|
|
|
end
|
|
|
|
|
2012-01-23 08:05:50 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|