One user one registration ticket

A user cannot have more than one registration ticket per conference.
This commit is contained in:
siddhantbajaj 2017-08-12 03:01:36 +05:30
parent de1fa448a2
commit 27bf79996d
8 changed files with 104 additions and 21 deletions

View file

@ -51,7 +51,11 @@ class User < ActiveRecord::Base
has_many :events_registrations, through: :registrations
has_many :ticket_purchases, dependent: :destroy
has_many :payments, dependent: :destroy
has_many :tickets, through: :ticket_purchases, source: :ticket
has_many :tickets, through: :ticket_purchases, source: :ticket do
def for_registration conference
where(conference: conference, registration_ticket: true).first
end
end
has_many :votes, dependent: :destroy
has_many :voted_events, through: :votes, source: :events
has_many :subscriptions, dependent: :destroy