I have a Competition and a Competition Entry model, the former includes a form and an optional "Question" field which isn't displayed if the admin user doesn't fill it out.
The Competition Entry model includes an "Answer" field that only needs to be validated if the question is present, but I'm not sure how to achieve that - is there a way to take advantage of the belongs_to/has_many association they have?
You can make validations conditional on a method, and in that method check the associated model.
class CompetitionEntry < ActiveRecord::Base
validates :answer, :presence => true, :if => :validate_answer?
def validate_answer?
!self.competition.question.blank?
end
end