/ Published in: Rails
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
class Product < ActiveRecord::Base validate :must_go_on_sale_before_event_starts # has scheduled_for datetime protected def must_go_on_sale_before_event_starts errors.add(:scheduled_for, 'should be before starts at') if scheduled_for > behaviour.starts_at || behaviour.starts_at < scheduled_for end end class Product::Event < ActiveRecord::Base # has starts_at datetime