Tag : rubyonrails
Tag : rubyonrails
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
Categories: Ruby On 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
1 2 3 4 |
# config.authentication_keys = [:email] config.authentication_keys = [:user_name] |
In the model rb (user.rb in my case) file,
1 2 3 4 5 6 7 8 9 |
def email_required? false end def email_changed? false end |
Categories: Ruby On Rails
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
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.
1 2 3 4 |
<%= stylesheet_link_tag 'default', media: 'all', 'data-turbolinks-track' => true %> <%= javascript_include_tag 'default', 'data-turbolinks-track' => true %> |
Categories: Ruby On Rails