私は少なくとも2つのクラスを持っています。1 つのクラスは、関連付けられたモデルの属性の値に基づいて、その属性の 1 つを検証する必要があります。以下のコードは私が目指しているものですが、それは単なるアイデアであり、機能しません。それを達成する方法はありますか?
class Concert
 include Mongoid::Document
 include Mongoid::Timestamps
 field :end_date, type: Date
end
class Sale
  include Mongoid::Document
  field :end_date, type: Date
  belongs_to :concert
  validates :end_date, :timeliness => {
        :before => lambda {self.concert.end_date}, 
        :after => lambda {self.concert.created_at}, 
        :before_message => 'Sale should not end before the Concert begins', 
        :after_message => 'Sale should not end after the Concert has already ended',
        :type => :date
    }
end