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

Invitation Accept Doesn't Work As Expected With Rails + Turbo #865

Closed
Petercopter opened this issue Dec 6, 2021 · 2 comments
Closed

Invitation Accept Doesn't Work As Expected With Rails + Turbo #865

Petercopter opened this issue Dec 6, 2021 · 2 comments

Comments

@Petercopter
Copy link

Steps to reproduce in a Turbo enabled Rails application:

When accepting an invitation, if the form submit fails (passwords don't match), there's no feedback to the user because Turbo expects a 422 Unprocessable Entity code back in order to re-render.

To mitigate this there's two options that I know of:

  1. Override the invitation controller and change
respond_with_navigational(resource) { render :edit }

to

respond_with_navigational(resource) { render :edit, status: :unprocessable_entity }
  1. Change the view form action from
   <%= simple_form_for(resource, as: resource_name, url: invitation_path(resource_name), html: { method: :put }) do |f| %>

to

<%= simple_form_for(resource, as: resource_name, url: invitation_path(resource_name), data: { turbo: false }, html: { method: :put }) do |f| %>

I think Devise already made this change, but I haven't looked into in awhile.

@scambra
Copy link
Owner

scambra commented Dec 10, 2021

I think devise did first way, I can see status: :unprocessable_entity in devise controllers, but I don't see turbo: false

Can you send PR with first way to fix it?

@Petercopter
Copy link
Author

@scambra Sorry I just saw this, thank you very much for the fix!!! 👍 🎉

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