0

I'm making rails + Devise + Bootstrap app. Basically it seems like working well, but when it gets wrong password , no error message is shown like this. enter image description here

I can't figure out why it happened and how to fix it. Could you give me any advise for that? Thanks in advance!

Noriaki Takamizawa
  • 887
  • 1
  • 10
  • 25

1 Answers1

0

Add these lines above the yield block in your application layout as suggested in one comment.

    # In application.html.erb
<% flash.each do |name, msg| %>

  # New code (allow for flash elements to be arrays)
  <% if msg.class == Array %>
    <% msg.each do |message| %>
      <%= content_tag :div, message, :id => "flash_#{name}" %>
    <% end %>
  <% else %>

    # old code
    <%= content_tag :div, msg, :id => "flash_#{name}" %>

  <% end %> #don't forget the extra end
<% end %>

Just add this code in the controller action, where you want to show the error messages,

flash[:notice] = flash[:notice].to_a.concat resource.errors.full_messages

This link gives you many answers for this

Community
  • 1
  • 1
Sravan
  • 18,467
  • 3
  • 30
  • 54
  • Thanks for the comment. When I put the code above in the application.html.slim and put latter code into application_controller.rb, another error comes up like "Couldn't find Users::OmniauthCallbacksHelper, expected it to be defined in helpers/users/omniauth_callbacks_helper.rb". This time I need to put devise error in my app. And the model is User, so where to write the code above? – Noriaki Takamizawa Oct 22 '16 at 09:11