heartcombo / devise

Flexible authentication solution for Rails with Warden.
http://blog.plataformatec.com.br/tag/devise/
MIT License
24k stars 5.55k forks source link

Devise error messasge do not shows proper #5530

Closed TangMonk closed 1 year ago

TangMonk commented 2 years ago

Fresh install Rails 7 and and devise 4.8.1

If I login in with wrong password, a flash error message will show up to page, like following screenshot:

enter image description here

But the weird thing is that flash error message is append to the end of html, like following screenshot:

enter image description here

the _error_message.html.erb is located in app/views/deivse/shared:

<% if resource.errors.any? %>
<div class="alert alert-primary" role="alert">
  <div id="error_explanation">
    <h2>
      <%= I18n.t("errors.messages.not_saved",
                 count: resource.errors.count,
                 resource: resource.class.model_name.human.downcase)
       %>
    </h2>
    <ul>
      <% resource.errors.full_messages.each do |message| %>
        <li><%= message %></li>
      <% end %>
    </ul>
  </div>
</div>
<% end %>

I try to change above error view file, but the flash message still not change, even I empty the error view file.

ksnitsky commented 2 years ago

Adding data: { turbo: false } to form fixed the problem for me, but now the whole page reloads when the form is submitted.

Looks like a problem with turbo_stream rendering.

scratchoo commented 1 year ago

same issue here! any solution?

gardnerapp commented 1 year ago

see Issue for other ways to fix this and this pull request

carlosantoniodasilva commented 1 year ago

The main branch should contain all that's necessary for fully working with Turbo now, which should fix this. A new version will be released soon, but feel free to test it out from the main branch in the meantime, and report back on any issues. Thanks.