Fix #1165 - before_action was called before protect_from_forgery
This commit is contained in:
parent
a872f2f4c6
commit
4b621188ad
4 changed files with 21 additions and 11 deletions
|
@ -4,13 +4,25 @@ module Localized
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
before_action :set_locale
|
||||
around_action :set_locale
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_locale
|
||||
I18n.locale = current_user.try(:locale) || default_locale
|
||||
rescue I18n::InvalidLocale
|
||||
I18n.locale = default_locale
|
||||
locale = default_locale
|
||||
|
||||
if user_signed_in?
|
||||
begin
|
||||
locale = current_user.try(:locale) || default_locale
|
||||
rescue I18n::InvalidLocale
|
||||
locale = default_locale
|
||||
end
|
||||
end
|
||||
|
||||
I18n.with_locale(locale) do
|
||||
yield
|
||||
end
|
||||
end
|
||||
|
||||
def default_locale
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue