1

This is my code for a devise user , i have two types of users in the application .How do i display error messages besides the fields that they arise in . As you can see , i have used devise for the users.I have been using <%= f.error_notification %> for displaying the errors but devise isn't showing it . All i see is "Please review the problems below" . Still learning on devise error views , any help on the same would be much appreciated .

<%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>  

   <div class="reg-gray-box fl">


                  <ul class="reg-form">
                      <li>
                          <%= f.input :email, :label => "Email Address", :placeholder => "Email", :required => false, :autofocus => true, input_html: { class: 'wh-txt-box' } %> 
                      </li>
                      <li>
                          <%= f.input :password, :label => "Password", :placeholder => "Password", :required => false, input_html: { class: 'wh-txt-box' } %> 
                      </li>                         
                      <li>
                          <%= f.button :submit, "Sign In", :class => 'big-blue-btn' %> 
                      </li>  
                     <li>
                    <%= link_to "Forgot your password?", new_password_path(resource_name), :class =>'link' %>
                   </li>                                            
                  </ul>



    </div>

 <% end %>
2
  • Please reformat your code to human-readable form. Commented Aug 11, 2014 at 10:52
  • Thanks. I had the same problem. Commented Aug 13, 2015 at 2:45

2 Answers 2

2

Insert this <%= devise_error_messages! %> line under this one <%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>. Like this:

<%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>  
  <%= devise_error_messages! %>
  ...

I would recommend prior asking the question to appeal to documentation first, specially in such well documented cases.

Sign up to request clarification or add additional context in comments.

Comments

0

Try the below one it will display the error messages.

Just add before_action :authenticate_user! in your controller.

Thanks, Vinod

1 Comment

Can you re-format your answer and tell where should i be posting it ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.