Use self.name for same-table relations
Personally reading the class name made me take some time to realize it was a same-table relation.
This commit is contained in:
@@ -12,8 +12,8 @@ class Budget
|
||||
include Sanitizable
|
||||
|
||||
belongs_to :budget
|
||||
belongs_to :next_phase, class_name: "Budget::Phase"
|
||||
has_one :prev_phase, class_name: "Budget::Phase", foreign_key: :next_phase_id
|
||||
belongs_to :next_phase, class_name: self.name
|
||||
has_one :prev_phase, class_name: self.name, foreign_key: :next_phase_id
|
||||
|
||||
validates_translation :summary, length: { maximum: SUMMARY_MAX_LENGTH }
|
||||
validates_translation :description, length: { maximum: DESCRIPTION_MAX_LENGTH }
|
||||
|
||||
@@ -8,7 +8,7 @@ class RelatedContent < ApplicationRecord
|
||||
belongs_to :author, class_name: "User"
|
||||
belongs_to :parent_relationable, polymorphic: true, touch: true
|
||||
belongs_to :child_relationable, polymorphic: true, touch: true
|
||||
has_one :opposite_related_content, class_name: "RelatedContent", foreign_key: :related_content_id
|
||||
has_one :opposite_related_content, class_name: self.name, foreign_key: :related_content_id
|
||||
has_many :related_content_scores
|
||||
|
||||
validates :parent_relationable_id, presence: true
|
||||
|
||||
Reference in New Issue
Block a user