Home > Back-end >  Rails Devise : serial alerts repeating
Rails Devise : serial alerts repeating

Time:11-14

I'm working on my login page with the Devise Gem. I encounter this weird thing when i click on the buttons. The messages displays itself at the end of the former one instead of replacing it. Do you know the potential reason of this strange behavior? Thanks a lot!

My session/new.rb

<h2>Log in</h2>

<%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
  <div >
    <%= f.input :email,
                required: false,
                autofocus: true,
                input_html: { autocomplete: "email" } %>
    <%= f.input :password,
                required: false,
                input_html: { autocomplete: "current-password" } %>
    <%= f.input :remember_me, as: :boolean if devise_mapping.rememberable? %>
  </div>

  <div >
    <%= f.button :submit, "Log in" %>
  </div>
<% end %>

<%= render "users/shared/links" %>

A picture of the render in the browser login page

I tried to find where i can limit this behaviour but unfortunately i didn't found it.

CodePudding user response:

When you login unsuccessfully.

It will render flash

Ex: flash[:alert] = "You need to sign in ...."

After that, in application.html.erb display this error

    <p ><%= notice %></p>
    <p ><%= alert %></p>

Make sure notice and alert in front of <%= yield %> and no repeat alert or notice

  • Related