You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The passwordless route helpers clobber root_url and other route helpers inside the /users namespace.
For example, if you have a 'WelcomeController#index' action, configured in routes.rb with passwordless:
Rails.application.routes.draw do
passwordless_for :users
root 'welcome#index'
end
If you are inside app/views/welcome/index.html.erb and you reference root_url from your shared application.html.erb layout, you get what you expect:
<%= root_url %> <!-- outputs "/" as expected -->
But if you use that same application.html.erb layout to render the bundled passwordless views, and try to link back home, you will get /users prefixed onto ALL OF YOUR ROUTES!
For example, if you call root_url inside application.html.erb rendered from app/views/passwordless/sessions.new.html.erb you will get AN INCORRECT URL!
Your routes should use main_app.projects_path and users.sign_in_path for the link helpers. It's cumbersome and frequently missed so I'm looking to removing it in 1.0 (#89).
Feel free to reopen if I'm misunderstanding something.
The passwordless route helpers clobber
root_url
and other route helpers inside the/users
namespace.For example, if you have a 'WelcomeController#index' action, configured in routes.rb with passwordless:
If you are inside
app/views/welcome/index.html.erb
and you referenceroot_url
from your sharedapplication.html.erb
layout, you get what you expect:<%= root_url %> <!-- outputs "/" as expected -->
But if you use that same
application.html.erb
layout to render the bundled passwordless views, and try to link back home, you will get/users
prefixed onto ALL OF YOUR ROUTES!For example, if you call
root_url
insideapplication.html.erb
rendered fromapp/views/passwordless/sessions.new.html.erb
you will get AN INCORRECT URL!<%= root_url %> <!-- outputs "/users" incorrectly! -->
The only fix I have found is to NOT use the default
passwordless_for
and instead pass/
to it:Now visiting
/sign_in
does NOT prefix all your routes with/users
includingroot_url
and other helpers.Happy to be corrected if wrong, but I think your routing is clobbering a namespace and should be implemented differently.
Thanks.
The text was updated successfully, but these errors were encountered: