I need to display error message on model in rails,
my coding on model is like this,
if my_address.valid?
# I need here the validation error.
return nil
end
I used errors.add(“Invalid address”) but it is not working
please help to solve this problem ,
I suggest taking a look at how scaffolds (
script/generate scaffold my_model) displays validation errors.Here’s a short summary:
In the “new” view, you’ll use
@post.errors, most likely with<%= error_messages_for :post %>.