Added a validation on created at attribute of Registration model
This commit is contained in:
parent
61930f8572
commit
0b435e6567
1 changed files with 7 additions and 0 deletions
|
|
@ -27,6 +27,7 @@ class Registration < ActiveRecord::Base
|
|||
validates_uniqueness_of :user_id, scope: :conference_id, message: 'already Registered!'
|
||||
validate :registration_limit_not_exceed, on: :create
|
||||
validate :registration_to_events_only_if_present
|
||||
validate :before_end_of_registration_period, on: :create
|
||||
|
||||
after_create :set_week, :subscribe_to_conference, :send_registration_mail
|
||||
|
||||
|
|
@ -59,6 +60,12 @@ class Registration < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def before_end_of_registration_period
|
||||
if conference && conference.registration_period && conference.registration_period.end_date && (Date.today > conference.registration_period.end_date)
|
||||
errors.add(:created_at, "can't be after the registration period end date!")
|
||||
end
|
||||
end
|
||||
|
||||
def subscribe_to_conference
|
||||
Subscription.create(conference_id: conference.id, user_id: user.id)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue