1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-10 21:24:20 +01:00
fab-manager/app/models/event_price_category.rb

22 lines
459 B
Ruby
Raw Normal View History

# frozen_string_literal: true
# EventPriceCategory is the relation table between Event and PriceCategory.
2020-03-25 10:16:47 +01:00
class EventPriceCategory < ApplicationRecord
2016-08-24 12:30:48 +02:00
belongs_to :event
belongs_to :price_category
2016-08-25 14:13:30 +02:00
has_many :tickets
2016-08-25 14:13:30 +02:00
validates :price_category_id, presence: true
validates :amount, presence: true
before_destroy :verify_no_associated_tickets
protected
def verify_no_associated_tickets
throw(:abort) unless tickets.count.zero?
end
2016-08-24 12:30:48 +02:00
end