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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s