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

23 lines
763 B
Ruby
Raw Normal View History

# frozen_string_literal: true
# PriceCategory is a way to segment prices for an Event.
# By default, each Events have a standard price but you may want, for example, to define a reduced fare for students,
# and another reduced fare for children under 8. Each of these prices are defined in an EventPriceCategory.
# You can choose to use each PriceCategory or not, for each Event you create.
2020-03-25 10:16:47 +01:00
class PriceCategory < ApplicationRecord
2016-08-24 12:30:48 +02:00
has_many :event_price_category
has_many :events, through: :event_price_categories
validates :name, presence: true
validates :name, uniqueness: { case_sensitive: false }
validates :conditions, presence: true
2016-08-24 16:52:37 +02:00
2016-08-24 12:30:48 +02:00
def safe_destroy
if event_price_category.count.zero?
2016-08-24 12:30:48 +02:00
destroy
else
false
end
end
end