设计Flash消息不显示 [英] Devise flash messages don't show up
问题描述
Devise在我的应用程序中完美地工作,除了来自devise.en.yml的flash消息不会在视图中显示。我做错了什么?
Devise works perfectly in my app except for flash messages from devise.en.yml doesn't get displayed in the view. What am I doing wrong?
以下是我的注册页面视图,我尝试过:alert
和:notice
but not work。
Below is my sign up page view i have tried both :alert
and :notice
but not working.
提前谢谢
<h2>Sign up</h2>
<% if flash[:alert] %>
<%=flash[:alert]%>
<%end%>
<%= form_for(resource,:as=>resource_name,:url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<p><%= f.label :Username %></p>
<p><%= f.text_field :username %></p>
<p><%= f.label :email %></p>
<p><%= f.text_field :email %></p>
<p><%= f.label :password %></p>
<p><%= f.password_field :password %></p>
<p><%= f.label :password_confirmation %></p>
<p><%= f.password_field :password_confirmation %></p>
<p><%= f.submit "Sign up" %></p>
<% end %>
<%= render :partial => "devise/shared/links" %>
推荐答案
你尝试取出Flash的东西吗? devise_error_messages应该照顾他们。我的工作没有它,原始的设计视图也没有: https://github.com/plataformatec/devise/blob/master/app/views/devise/registrations/new.html.erb
Have you tried taking out the flash stuff ? The devise_error_messages should take care of them. Mine works without it, and the original devise view doesn't have it either: https://github.com/plataformatec/devise/blob/master/app/views/devise/registrations/new.html.erb
这篇关于设计Flash消息不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!