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

Non-passwordless route path helpers are prefixed with /users when rendering passwordless templates #30

Closed
abevoelker opened this issue Nov 1, 2018 · 2 comments

Comments

@abevoelker
Copy link

Given this routes file:

# config/routes.rb
Rails.application.routes.draw do
  resources :stripe_charges, only: [:create]
  passwordless_for :users
end

And this application layout (app/views/layouts/application.html.erb):

<!DOCTYPE html>
<html>
  <head>
    <title>foo</title>
    <%= csrf_meta_tags %>
    <%= csp_meta_tag %>
    <%= stylesheet_link_tag    'application', media: 'all' %>
    <%= javascript_include_tag 'application' %>
  </head>

  <body>
    <nav>
      <form action="<%= stripe_charges_path %>" method="POST"></form>
    </nav>
    <%= yield %>
  </body>
</html>

When the application layout is rendered on normal pages, stripe_charges_path correctly returns /stripe_charges, but when rendered as part of a Passwordless template like app/views/passwordless/sessions/new.html.erb, it is returning /users/stripe_charges, which doesn't exist.

@abevoelker abevoelker changed the title Non-passwordless route path helpers are prefixed with /users inside passwordless's templates Non-passwordless route path helpers are prefixed with /users when rendering passwordless templates Nov 1, 2018
@mikker
Copy link
Owner

mikker commented Nov 1, 2018

This is due to Passwordless isolating its engine namespace. In your case, every view rendered by a Passwordless action (including the layout) has to prefix the main app's routes with main_app. eg. main_app.stripe_charges_path.

It's really annoying and I've been looking into removing the isolation, see #22.

I don't know when I'll have the time to finalize it though – PRs very welcome.

@mikker mikker closed this as completed Nov 1, 2018
@abevoelker
Copy link
Author

Got it, thanks for the explanation!

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