Created
October 14, 2008 14:48
-
-
Save sandro/16721 to your computer and use it in GitHub Desktop.
change error message name for fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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