Skip to content

Instantly share code, notes, and snippets.

@sandro
Created October 14, 2008 14:48
Show Gist options
  • Save sandro/16721 to your computer and use it in GitHub Desktop.
Save sandro/16721 to your computer and use it in GitHub Desktop.
change error message name for fields
class User
validates_presence_of :terms_accepted, :message => 'must be accepted'
protected
HUMANIZED_ATTRIBUTES = {
:terms_accepted => 'Terms and Conditions'
}
def self.human_attribute_name(attr)
HUMANIZED_ATTRIBUTES[attr.to_sym] || super
end
end
# Error message will become "Terms and Conditions must be accepted" instead of "Terms accepted must be accepted"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment