Here is my code:
<% @user.errors.each do |key, value| %>
<% puts 'key is' + key.to_s + 'value is ' + value.to_s %>
<% if key == 'email' %>
<% puts 'key is def email' %>
<% else %>
<% puts 'key is def not email' %>
<% end %>
<% end %>
This outputs:
key isemailvalue is can't be blank
key is def not email
key ispassword_confirmationvalue is doesn't match Password
key is def not email
key isprofile_namevalue is This is not valid.
key is def not email
The problem is that it is saying "key is def not email" even when they key definitely is "email" How do I fix this? Thanks
+to build string. Do not useputsin ERb.Y ou can write it in more readable way by this:key is <%= key %>, value is <%= value %>.<%=d key %>.dis a helper function that inspects the value. That way you'll find out what key really is.