TIP : Showing login failure message in devise views in rails

While working with devise gem, I need to show the failure messages like “Invalid username / password” (As shown in the below image) when user enters a wrong username/password.

Invalid_Credential

I have added the flash massage to show the error as shown in below code in app/view/devise/sessions/new

Hope this helps

Categories: Ruby On Rails

Tip : Making email as optional (not mandatory) field in devise in Rails

This situation arises, when we need to login through a different unique key other than email and wanted email to be optional in the entry form.

Prerequisites

Make sure in config/initializers/devise.rb to set the config.authentication_keys to some other field (not email, which is default) in devise.rb

Now, let’s do

In the model rb (user.rb in my case) file,

Categories: Ruby On Rails

%d bloggers like this: