Add valuation comments relation at Budget Investment
Why: Budget Investments already has an existing `comments` relation that is on use. We need to keep that relation unaltered after adding the internal valuation comments, that means scoping the relation to only public comments (non valuation ones) so existing code using it will remain working as expected. A new second relation will be needed to explicitly ask for valuation comments only where needed, again scoping to valuation comments. How: Adding a second `valuations` relationship and filtering on both with the new `valuation` flag from Comment model.
This commit is contained in:
@@ -34,7 +34,10 @@ class Budget
|
|||||||
|
|
||||||
has_many :valuator_assignments, dependent: :destroy
|
has_many :valuator_assignments, dependent: :destroy
|
||||||
has_many :valuators, through: :valuator_assignments
|
has_many :valuators, through: :valuator_assignments
|
||||||
has_many :comments, as: :commentable
|
|
||||||
|
has_many :comments, -> {where(valuation: false)}, as: :commentable, class_name: 'Comment'
|
||||||
|
has_many :valuations, -> {where(valuation: true)}, as: :commentable, class_name: 'Comment'
|
||||||
|
|
||||||
has_many :milestones
|
has_many :milestones
|
||||||
|
|
||||||
validates :title, presence: true
|
validates :title, presence: true
|
||||||
|
|||||||
Reference in New Issue
Block a user