How to customize the humanized :category
symbol in the generated error message.
Tested with Rails 4.1
class Listing < ActiveRecord::Base
validate :premium_category
private
def premium_category
if !user.is_premium && %w(tigers lions rhinos).include?(category))
errors.add(:category, "not valid for non premium users")
end
end
end
config/locales/en.yml
en
activerecord:
attributes:
listing:
category: "This category is "
This will generate the following error message:
This category is not valid for non premium users