Create RelatedContent model
This commit is contained in:
11
app/models/related_content.rb
Normal file
11
app/models/related_content.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class RelatedContent < ActiveRecord::Base
|
||||
belongs_to :parent_relationable, polymorphic: true
|
||||
belongs_to :child_relationable, polymorphic: true
|
||||
|
||||
validates :parent_relationable_id, presence: true
|
||||
validates :parent_relationable_type, presence: true
|
||||
validates :child_relationable_id, presence: true
|
||||
validates :child_relationable_type, presence: true
|
||||
validates :parent_relationable_id, uniqueness: { scope: [:parent_relationable_type, :child_relationable_id, :child_relationable_type] }
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user