I have this in comment.rb:
def create_notification
self.notifications.create(
comment: self,
goal: self.goal,
valuation: self.valuation,
user: # How to fix this line?
if valuation
self.valuation.user,
else goal
self.goal.user,
end
read: false
)
end
How can we make it where when the comment is on a valuation the notification uses user: self.valuation.user
and when the comment is on a goal it uses user: self.goal.user
?
Here's previous question if you need more context: How to send Notifications to the User whose post received a Comment?
I would write something like this: