Devise 密码重置错误消息出现在 devise_error_messages 中但不闪烁?
在我的 Rails 3 应用程序中,我使用 devise。对于密码重置表单,我有:
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>
......
我想删除 devise_error_message 并坚持使用 Rails Flash,但这不起作用,因为错误没有发送到闪存?
<% flash.each do |key, value| %>
<div id="message-drawer">
<div class="message error">
<div class="message-inside"><span><%= value %></span>
</div>
</div>
</div>
<% end %>
闪存为空?为什么?谢谢
in my rails 3 app I use devise. For the password reset form I have:
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>
......
I want to remove the devise_error_message and stick with the rails flash, but that's not working as the errors are not being sent to flash?
<% flash.each do |key, value| %>
<div id="message-drawer">
<div class="message error">
<div class="message-inside"><span><%= value %></span>
</div>
</div>
</div>
<% end %>
flash is empty? Why? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
flash 是空的,因为这些是使用辅助方法 devise_error_message 打印的模型验证错误消息! 。您始终可以覆盖它:
https://github.com/plataformatec/devise/blob/master /app/helpers/devise_helper.rb
但是通过 I18n 文件自定义与设备相关的消息要容易得多:
config/locales/devise.en.yml
flash is empty because those are model validation error messages which are printed using the helper method devise_error_message! . You can always override it:
https://github.com/plataformatec/devise/blob/master/app/helpers/devise_helper.rb
But it is a lot easier to customize your devise related messages via the I18n file:
config/locales/devise.en.yml
默认情况下,设备仅使用闪现消息进行登录和注销。任何表单错误都会在下次重新加载时与表单一起打印。考虑修改控制器以生成适当的闪存消息。
By default devise only uses flash messages for sign in and sign out. Any form errors are printed inline with the form on the next reload. Consider modifying the controller to generate the appropriate flash messages.