Display customize column name in ActiveRecord validation

There are number of ways to set custom column name ,

But i generally preferred following .

HUMANIZED_ATTRIBUTES = {:p_type=> "Advertise type", :body=>"Description"}

def self.human_attribute_name(attr)
HUMANIZED_ATTRIBUTES[attr.to_sym] || super
end

Now we can set custom column name , good to go.

Advertisements