Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing locale as a symbol should work. #207

Closed
jamesst20 opened this issue Mar 13, 2020 · 3 comments
Closed

Passing locale as a symbol should work. #207

jamesst20 opened this issue Mar 13, 2020 · 3 comments

Comments

@jamesst20
Copy link

Rails : 5.0.7.1
route_translator: 7.1.2
ruby : 2.4.9

Upgrading from Rails 4 to Rails 5 have broken all my tests using localized paths.

Behavior

# Works on Rails 4, fails on Rails 5
post :login_password, params: { locale: I18n.locale, client: { email: client.email } }

Exception

Minitest::UnexpectedError: ActionController::UrlGenerationError: No route matches {:action=>"login_password", :client=>{:email=>"[email protected]"}, :controller=>"sites", :locale=>:"en-ca"}

Temporary Fix (adding .to_s)

post :login_password, params: { locale: I18n.locale.to_s, client: { email: client.email } }
@tagliala
Copy link
Collaborator

Hi!

Thanks for being part of the route_translator community.

Passing locale as a symbol should work

Yes, it should, but it doesn't. :)

This is also documented in our wiki here: https://github.com/enriclluelles/route_translator/wiki/Generating-translated-URLs

The following considerations still apply #192 (comment)

Closing here as a duplicate of #192

@jamesst20
Copy link
Author

jamesst20 commented Mar 13, 2020

@tagliala

Thank you for the quick response, I will take a look.

A quick fix would not to be simply always calling "to_s" internally so the symbol gets converted to a string?

@tagliala
Copy link
Collaborator

A quick fix would not to be simply always calling "to_s" internally so the symbol gets converted to a string?

No, sorry, this is not that simple. I've tried without success.

I will add a note here too: https://github.com/enriclluelles/route_translator#testing The test example uses a string, but it does not specify that it is intended

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants