Friday, May 15, 2009

Validates_presence_of : customise field name

validates_presence_of :id_country, :message => "Country can't be blank"

class Adresse < ActiveRecord::Base

HUMANIZED_COLLUMNS = {:id_country => "Country"}

def self.human_attribute_name(attribute)
HUMANIZED_COLLUMNS[attribute.to_sym] || super
end
end

No comments:

Post a Comment