-
-
Save mharris717/248569 to your computer and use it in GitHub Desktop.
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 Client < ActiveRecord::Base | |
validates_presence_of :name, :zip, :address, :city, :phone_number | |
# only change the humanized text for zip and name. The other attributes will still be humanized | |
# just as they normally would. | |
HUMANIZED_COLUMNS = {:zip => "Postal code", :name => "Company contact name"} | |
def self.human_attribute_name(attribute) | |
HUMANIZED_COLUMNS[attribute.to_sym] || super | |
end | |
end | |
# Normally if we try to save a record without a name we would get the error message: | |
# Name can't be blank | |
# Using this method to change the humanized text we now get: | |
# Company contact name can't be blank |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment