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.rb

16 lines
464 B
Ruby
Raw Normal View History

2019-09-10 11:46:14 +02:00
# frozen_string_literal: true
# Store customized price for various items (Machine, Space), depending on the group and on the plan
2020-03-25 10:16:47 +01:00
class Price < ApplicationRecord
2016-03-23 18:39:41 +01:00
belongs_to :group
belongs_to :plan
belongs_to :priceable, polymorphic: true
validates :priceable, :group_id, :amount, presence: true
2021-12-21 17:13:40 +01:00
validates :priceable_id, uniqueness: { scope: %i[priceable_type plan_id group_id duration] }
def safe_destroy
destroy unless duration == 60
end
2016-03-23 18:39:41 +01:00
end