Files
nairobi/app/models/sdg/relation.rb
Javi Martín 101625ebab Touch the associated record when assigning targets
So the cache will expire properly.
2021-01-22 17:54:18 +01:00

7 lines
284 B
Ruby

class SDG::Relation < ApplicationRecord
validates :related_sdg_id, uniqueness: { scope: [:related_sdg_type, :relatable_id, :relatable_type] }
belongs_to :relatable, polymorphic: true, optional: false, touch: true
belongs_to :related_sdg, polymorphic: true, optional: false
end