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

16 lines
464 B
Ruby

# frozen_string_literal: true
# Store customized price for various items (Machine, Space), depending on the group and on the plan
class Price < ApplicationRecord
belongs_to :group
belongs_to :plan
belongs_to :priceable, polymorphic: true
validates :priceable, :group_id, :amount, presence: true
validates :priceable_id, uniqueness: { scope: %i[priceable_type plan_id group_id duration] }
def safe_destroy
destroy unless duration == 60
end
end