简体   繁体   中英

Make Devise error messages appear

In my application.html.erb file, I have

<% flash.each do |key,msg| %>
  <div class="message">
      <%= content_tag :div, msg %>
  </div>
<% end %>

Is there a way to make devise display it's error messages in there?

When I add <%= devise_error_messages! %> <%= devise_error_messages! %> I get a undefined local variable or method 'resource' error.

In application.html.erb file

<% [:notice,:error,:info,:success,:alert].each do |key| %>
  <div class="message">
    <%= flash[key] %>
  </div>
<% end %>

Just try to put a form_for with url so that devise will be able to check which resource it is referring to..

eg: <%form_for :post,:url=>post_path(@post) do |f|%>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM