mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-10 21:24:20 +01:00
22 lines
455 B
Ruby
22 lines
455 B
Ruby
# frozen_string_literal: true
|
|
|
|
# EventPriceCategory is the relation table between Event and PriceCategory.
|
|
class EventPriceCategory < ApplicationRecord
|
|
belongs_to :event
|
|
belongs_to :price_category
|
|
|
|
has_many :tickets
|
|
|
|
validates :price_category_id, presence: true
|
|
validates :amount, presence: true
|
|
|
|
before_destroy :verify_no_associated_tickets
|
|
|
|
protected
|
|
|
|
def verify_no_associated_tickets
|
|
throw(:abort) if tickets.count.zero?
|
|
end
|
|
|
|
end
|