Merge pull request #876 from rishabhs95/delete-tickets-unregistered
Destroying tickets belonging to a user after user unregisters from a conference
This commit is contained in:
commit
9e67a1bcd5
2 changed files with 30 additions and 8 deletions
|
|
@ -29,6 +29,7 @@ class Registration < ActiveRecord::Base
|
|||
validate :registration_limit_not_exceed, on: :create
|
||||
|
||||
after_create :set_week, :subscribe_to_conference, :send_registration_mail
|
||||
after_destroy :destroy_purchased_tickets
|
||||
|
||||
def week
|
||||
created_at.strftime('%W').to_i
|
||||
|
|
@ -36,6 +37,11 @@ class Registration < ActiveRecord::Base
|
|||
|
||||
private
|
||||
|
||||
def destroy_purchased_tickets
|
||||
ticket_purchased = TicketPurchase.where(conference_id: conference_id, user_id: user.id)
|
||||
ticket_purchased.destroy_all
|
||||
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