Sha256: c6c0c1e53384d8ac7e82b6c40293d4da2cb38b0280b0a99b9a45362bfaa55e67

Contents?: true

Size: 823 Bytes

Versions: 2

Compression:

Stored size: 823 Bytes

Contents

module IuguSDKBaseController

  def self.included(receiver)
    receiver.append_before_filter :configure_locale
  end

  def select_account
    set_account(current_user) if current_user
  end

  def configure_locale
    if(params[:hl])
      locale = params[:hl] if AvailableLanguage.all.values.include? params[:hl]
    end
    unless locale
      @matched_locale_from_browser = request.preferred_language_from(AvailableLanguage.all.values)
      if signed_in?
        if current_user.locale.blank?
          locale = "en" 
        else
          locale = current_user.locale
        end
      else
        locale = @matched_locale_from_browser
      end
    end
    I18n.locale = locale
  end

  def verify_api_key
    raise ActionController::RoutingError.new("iws_api_key missing") unless IuguSDK::iws_api_key
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
iugusdk-1.0.0.alpha.5 lib/iugusdk/iugusdk_base_controller.rb
iugusdk-1.0.0.alpha.4 lib/iugusdk/iugusdk_base_controller.rb