scinote-web/app/models/result_asset.rb

14 lines
345 B
Ruby
Raw Normal View History

2017-06-23 21:19:08 +08:00
class ResultAsset < ApplicationRecord
2016-02-12 23:52:43 +08:00
validates :result, :asset, presence: true
2017-06-28 21:21:32 +08:00
belongs_to :result, inverse_of: :result_asset, optional: true
belongs_to :asset,
inverse_of: :result_asset,
dependent: :destroy,
optional: true
2016-02-12 23:52:43 +08:00
def space_taken
asset.present? ? asset.estimated_size : 0
end
2016-02-12 23:52:43 +08:00
end