I'm trying to validate a model attribute based on a simple condition as shown in the rails docs. I have a quiz model with a boolean "show_birthday" attribute, and a participant model with a birthday attribute. Here's the relevant part of my code:
class Participant < ActiveRecord::Base
belongs_to :quiz
validates :birthday, presence: true, :if => :has_birthday?
def has_birthday?
quiz.show_birthday?
end
end
The validation works if I remove the if condition, but does not work even if I change the part inside the has_birthday? method to "true". Any ideas on why this isn't working?