Created
December 24, 2009 15:38
-
-
Save lightscalar/263237 to your computer and use it in GitHub Desktop.
This file contains 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
Just discovered this: an easy way to humanize the attributes of a model. Allows you to rename the database column name to something more reasonable. Makes for nicer, more understandable error messages back to the user. | |
class User < ActiveRecord::Base | |
HUMANIZED_ATTRIBUTES = { | |
:user_email => "E-mail address" | |
} | |
def self.human_attribute_name(attr) | |
HUMANIZED_ATTRIBUTES[attr.to_sym] || super | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment