Tag : rubyonrails

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.


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.


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

Multiple Submit buttons in a single view in Rails

While working in an assignment, I have to dealt with view where I have to re-send the verification code form the same view in which I have to accept the verification code.


As shown in the image, “Confirm” and “Resend code” both are 2 submit buttons. I need to resend another code from the same page without redirecting.

How I made it work ??

View part

Added both the submit buttons

Controller part

Handled the post action part

Categories: Ruby On Rails

Fixing ExecJS::ProgramError in page

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

ExecJS programError


After some search in Google, I got a solution from this link, which helped me fixing the issue. I also learned, It is an issue with the windows. The application parameter works on the web server.

Opened the application.html.erb in app/views/layouts folder of StaticPageDemo project. Replaced application with default.

Categories: Ruby On Rails

%d bloggers like this: