Guest User

Untitled

a guest
Aug 2nd, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. Devise, customizing the error messages?
  2. <% if @user.errors.any? %>
  3. <div id="error_explanation" class="error">
  4. <h2>Hold on!</h2>
  5. <ul>
  6. <% @user.errors.full_messages.each do |msg| %>
  7. <li><%= msg %></li>
  8. <% end %>
  9. </ul>
  10. </div>
  11. <% end %>
  12.  
  13. Email The User's Email cannot be blank
  14. Password The User's Password cannot be blank
  15. Fname The User's Fname is too short (minimum 1 characters)
  16. Lname The User's Lname is too short (minimum 1 characters)
  17.  
  18. validates_presence_of(*attr_names)
  19.  
  20. Configuration options:
  21. message - A custom error message (default is: "canβ€˜t be blank").
  22.  
  23. activerecord:
  24. attributes:
  25. user:
  26. email: "your_way_of_email"
  27. password: "your_way_of_password"
  28. password_confirmation: "your_way_of_password_confirmation"
  29.  
  30. <% if @user.errors.any? %>
  31. <div id="error_explanation" class="error">
  32. <h2>Hold on!</h2>
  33. <ul>
  34. <% @user.errors.each_key do |attr| %>
  35. <% @user.errors[attr].each do |msg| %>
  36. <% next if msg.nil? %>
  37.  
  38. <li><%= msg %></li>
  39. <% end %>
  40. <% end %>
  41. </ul>
  42. </div>
  43. <% end %>
Add Comment
Please, Sign In to add comment