Reputation: 9218
I want to display something like:
validates :field, :inclusion => { :in => fields, :message => "is not allowed: {self.field}"}
But the self is referring to the class itself rather than the instance variable.
Upvotes: 2
Views: 258
Reputation: 12998
If I understood it correctly, you want something like
class Coffee < ActiveRecord::Base
validates_inclusion_of :size, :in => %w(small medium large),
:message => "%{value} is not a valid size"
end
Upvotes: 2