Skip to content

Instantly share code, notes, and snippets.

@yoavmatchulsky
Created February 10, 2013 12:49
Show Gist options
  • Save yoavmatchulsky/4749498 to your computer and use it in GitHub Desktop.
Save yoavmatchulsky/4749498 to your computer and use it in GitHub Desktop.
Fix for setting a he locale (/he prefix) to named routes. Bug was that #url_for called from views didn't get the correct locale. Solved by set_locale if @locale.nil in #default_url_options
def set_locale
if @locale.nil?
I18n.locale = params[:locale] || I18n.default_locale
@locale = I18n.locale.to_sym
end
end
def default_url_options(options = {})
set_locale if @locale.nil?
if [:he].include? @locale
options.reverse_merge locale: @locale
else
options
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment