Rails group validation with just one error message

Posted by Victor on Stack Overflow See other posts from Stack Overflow or by Victor
Published on 2011-11-13T01:24:59Z Indexed on 2011/11/13 1:51 UTC
Read the original article Hit count: 192

The following validation code in the model:

validates :formatted_address, :zip, :city, :state, :country, :presence => true, :message => "is incomplete. Please enter full address."

is displayed when either of the fields are empty. Let's say now :address and country are empty, 2 errors are displayed:

Formatted Address is incomplete. Please enter full address.
Country is incomplete. Please enter full address.

How can I group the error message in the validation to just show one error message if either of the fields validated does not exist?

Address is incomplete. Please enter full address.

Thanks.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby-on-rails-3