I have successfully completed custom redirects after an unsuccessful login scheme for these links ...
Configure redirection after failed login https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-when-the-user-can-not-be-authenticated
However, I do not receive the corresponding flash messages on my static page. I tried adding a flash message to custom_failure.rb like this ...
def redirect_url login_path flash[:notice] = "Invalid login or password" end
... but there is no cigar. Ideally, I would like to display error messages by default. Any way to do this?
... also I display my login and registration pages on static pages in my application. So for instanced in app / views / static_pages / login.html.erb I have ...
<%= form_for("user", :url => user_session_path) do |f| %> <table> <tr> <td><%= f.label :email %></td> <td><%= f.text_field :email %></td> </tr> <td><%= f.label :password %></td> <td><%= f.password_field :password %></td> </table> <%= f.check_box :remember_me %> <%= f.label :remember_me %><p/> <%= f.submit 'Sign in' %><p/> <%= link_to "Forgot your password?", new_password_path('user') %> <% end %>
Test
source share