Category : Ruby On Rails
Category : Ruby On 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. I have added the flash massage to show the error as shown in below code in app/view/devise/sessions/new
1 2 3 |
<%= flash[:alert]%> |
Hope this helps
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
1 2 3 4 |
# config.authentication_keys = [:email] config.authentication_keys = [:user_name] |
Now, let’s do In the model rb (user.rb
I have manage to fix my ExecJS::ProgramError as mentioned in my last post.
The error got disappeared as soon as I change the “application” to “default”. But the issue I faced now is, my app is unable to locate and load the CSS and JS. None of the styles got loaded.
I tried to inspect the issue. Looked into the source rendered in the browser by choosing the “view source” option.
From the source it looks like the app is trying to locate the default.css and default.js, which is not present.
How I got the issue Created a new project in rails $ rails new StaticPageDemo Added static_page controller to it with home action $ rails generate controller static_page home Ran the server $ rails server Got this error while tried to access the page in http://localhost:3000/static_page/home Solution After some search in Google, I got a