Skip to content

Instantly share code, notes, and snippets.

@robmerrell
Created December 3, 2009 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save robmerrell/248335 to your computer and use it in GitHub Desktop.
Save robmerrell/248335 to your computer and use it in GitHub Desktop.
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