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

22 lines
620 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
2022-12-28 17:51:27 +01:00
has_many :tickets, dependent: :restrict_with_error
has_many :cart_item_event_reservation_tickets, class_name: 'CartItem::EventReservationTicket', dependent: :restrict_with_error
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