Sha256: 8b757f57315c221e30d9ca6b3c9e3d15b74805d96bc6510b32c57ce97cc568a3

Contents?: true

Size: 585 Bytes

Versions: 3

Compression:

Stored size: 585 Bytes

Contents

module Heart
  class ApplicationController < ActionController::Base
    protect_from_forgery
    before_filter :set_locale
    layout 'heart_engine'

    private

    def set_locale
      if !params[:lang].nil?
        supported_locales ||= I18n.available_locales.map {|x| x.to_s}
        if supported_locales.include?("#{params[:lang]}_heart")
          cookies.permanent[:heart_lang] = params[:lang]
        end
      end
      cookies.permanent[:heart_lang] = "en" if cookies[:heart_lang].nil?
      I18n.locale = "#{cookies[:heart_lang]}_heart"
      return true
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
heart-0.0.2 app/controllers/heart/application_controller.rb
heart-0.0.1 app/controllers/heart/application_controller.rb
heart-0.0.1.pre app/controllers/heart/application_controller.rb