app.new_user_session_path(locale: I18n.locale) should read "/es/users/sign_in", not "/users/sign_in?locale=es" #6

Closed
tute opened this Issue Sep 3, 2012 · 8 comments

Comments

Projects
None yet
5 participants
Contributor

tute commented Sep 3, 2012

Like your gem, and finding many issues while implementing it. How can we make app.new_user_session_path(locale: I18n.locale) generate /es/users/sign_in instead of /users/sign_in?locale=es?

Thank you again.

Owner

enriclluelles commented Sep 3, 2012

When route_translator adds the locale parameter to url hashes(which is why url_for uses for the matching) it adds the locale parameter as a string instead of a symbol. Running rake routes will show you what I'm talking about. And I18n.locale outputs a symbol

So, you should do:

    app.new_user_session_path(locale: I18n.locale.to_s)

I know that right now this is a bit cumbersome but I've yet to find a workaround for this. You're welcome to try :)

Contributor

tute commented Sep 4, 2012

Thank you @enriclluelles. However it doesn't change the behaviour:

> app.new_user_session_path(locale: :en)
 => "/users/sign_in?locale=en" 
> app.new_user_session_path(locale: 'en')
 => "/users/sign_in?locale=en" 

More over, if all URL helpers are trapped by route_translator we may be able to normalize parameters before actually building the URL, right? In that case I'll be able to help. :-)

Owner

enriclluelles commented Sep 4, 2012

This is weird... Can you show me the routes.rb file so I can investigate?

@enriclluelles enriclluelles reopened this Sep 4, 2012

Contributor

tute commented Sep 4, 2012

Oh, seems like it has to do with devise. Built a minimal application with following routes.rb file:

TranslateDeviseRoutes::Application.routes.draw do
  localized do
    devise_for :users, controllers: { sessions: 'sessions' }
    root :to => 'sessions#new'
  end
end

And rake routes shows:

        new_user_session GET    /users/sign_in(.:format)       sessions#new
            user_session POST   /users/sign_in(.:format)       sessions#create
    destroy_user_session DELETE /users/sign_out(.:format)      sessions#destroy
           user_password POST   /users/password(.:format)      devise/passwords#create
       new_user_password GET    /users/password/new(.:format)  devise/passwords#new
      edit_user_password GET    /users/password/edit(.:format) devise/passwords#edit
                         PUT    /users/password(.:format)      devise/passwords#update
cancel_user_registration GET    /users/cancel(.:format)        devise/registrations#cancel
       user_registration POST   /users(.:format)               devise/registrations#create
   new_user_registration GET    /users/sign_up(.:format)       devise/registrations#new
  edit_user_registration GET    /users/edit(.:format)          devise/registrations#edit
                         PUT    /users(.:format)               devise/registrations#update
                         DELETE /users(.:format)               devise/registrations#destroy
                    root        /                              sessions#new

I guess I'll have to route without using devise_for block?

Best.

Owner

enriclluelles commented Sep 4, 2012

I will look into what's happening here. Good catch

On Tuesday, September 4, 2012 at 6:31 PM, Tute Costa wrote:

Oh, seems like it has to do with devise. Built a minimal application with following routes.rb file:
TranslateDeviseRoutes::Application.routes.draw do localized do devise_for :users, controllers: { sessions: 'sessions' } root :to => 'sessions#new' end end
And rake routes shows:
new_user_session GET /users/sign_in(.:format) sessions#new user_session POST /users/sign_in(.:format) sessions#create destroy_user_session DELETE /users/sign_out(.:format) sessions#destroy user_password POST /users/password(.:format) devise/passwords#create new_user_password GET /users/password/new(.:format) devise/passwords#new edit_user_password GET /users/password/edit(.:format) devise/passwords#edit PUT /users/password(.:format) devise/passwords#update cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel user_registration POST /users(.:format) devise/registrations#create new_user_registration GET /users/sign_up(.:format) devise/registrations#new edit_user_registration GET /users/edit(.:format) devise/registrations#edit PUT /users(.:format) devise/registrations#update DELETE /users(.:format) devise/registrations#destroy root / sessions#new
I guess I'll have to route without using devise_for block?
Best.


Reply to this email directly or view it on GitHub (#6 (comment)).

Senjai commented Jan 19, 2015

@enriclluelles What was the result of your investigation?

Collaborator

tagliala commented May 25, 2016

Hi, please do not +1 here

I don't know why this is closed but please open a new request explaining what is happening and providing a failing test case (or a minimal application hosted on github).

Then I will add a "help wanted" label.

PR are welcomed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment