Created
March 14, 2011 14:30
-
-
Save rvanlieshout/869208 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Registration < ActiveRecord::Base | |
# Database Relationships | |
belongs_to :person | |
belongs_to :event | |
# Validations | |
validates_presence_of :event_id | |
validates_presence_of :person_id | |
validates_uniqueness_of :person_id, :scope => :event_id, :message => "is already signed in or registered." | |
validate do |registration| | |
registration.errors.add(:event, :passed) if registration.event && registration.event.finish < Time.now | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment