简体   繁体   中英

Devise Password Reset error message appears in the devise_error_messages but not flash?

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

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.

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

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