Created
November 26, 2013 15:01
-
-
Save kelso/7659826 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
# Prevent CSRF attacks by raising an exception. | |
# For APIs, you may want to use :null_session instead. | |
protect_from_forgery with: :exception | |
before_action :set_locale | |
before_action :set_cart | |
def set_cart | |
@cart = ShoppingCart.new(session) | |
end | |
protected | |
def extract_locale_from_tld | |
parsed_locale = request.host.split('.').last | |
I18n.available_locales.include?(parsed_locale.to_sym) ? parsed_locale : nil | |
end | |
def set_locale | |
I18n.locale = extract_locale_from_tld || I18n.default_locale | |
end | |
def set_admin_locale #this method is used in initializers/active_admin.rb | |
I18n.locale = :en | |
end | |
<<<<<<< HEAD | |
def extract_locale_from_tld | |
parsed_locale = request.host.split('.').last | |
I18n.available_locales.include?(parsed_locale.to_sym) ? parsed_locale : nil | |
end | |
def set_cart | |
segment = client_signed_in? ? current_client.segment.try(:downcase).try(:first) : "n/a" | |
@cart = ShoppingCart.new(session, segment) | |
end | |
======= | |
>>>>>>> develop | |
# use this method when popup flash needed (overlay) | |
def set_popup_notice body | |
flash[:notice] = body | |
flash[:in_popup] = true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment