简体   繁体   中英

Devise login error messages

I'm trying to access the login errors messages the same way as I access errors in signup. In my case, whether the user has already confirmed the email or not.

<% = F.error_notification %>

But in login, does not show any error.

Someone?

UPDATE

As Nitish Parkar said, in our login page, error messages are shown in flash messages.

Thank you!

Devise returns errors in a slightly annoying way that might not be compatible with the way you usually display errors in your templates. I end up assigning them in an overridden controller.

def create
   build_resource(sign_up_params)
   resource_saved = resource.save
   yield resource if block_given?
   if resource_saved
     if resource.active_for_authentication?
       set_flash_message :notice, :signed_up if is_flashing_format?
       sign_up(resource_name, resource)
       respond_with resource, location: after_sign_up_path_for(resource)
     else
       set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
       expire_data_after_sign_in!
       respond_with resource, location: after_inactive_sign_up_path_for(resource)
     end
   else
     clean_up_passwords resource
     @validatable = devise_mapping.validatable?
     if @validatable
       @minimum_password_length = resource_class.password_length.min
     end
     #respond_with resource
     flash[:error] = resource.errors.full_messages
     redirect_to '/signup'
   end
 end


 <% if !flash.empty? %>
   <div class="alert alert-success lead">
     <% flash.each do |name, msg| -%>
       <%= content_tag :div, msg, class: name %>
     <% end -%>
   </div>
 <% end %>

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