Having trouble marking notifications as read for polymorphic comments #278
Unanswered
DebakeDSP94
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Hey @DebakeDSP94 ! It looks like your query for notification is what's wrong |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi. Please forgive my newness to rails. I currently learning from The Odin Project. I'm using the noticed gem in my facebook clone app. I plan to eventually add nested comments, and notifications for likes and friend requests, but I want to get them working properly on comments first and then move forward. The notifications are working, and are correctly linking to the post as intended. The issue I'm having is in marking them as read. I followed this tutorial, but had to change some things to have it work with polymorphic comments, and I think that's where my issue is. https://youtu.be/c570-wnW_-A
def mark_notifications_as_read if current_member notifications_to_mark_as_read = @post.notifications_as_post.where(recipient: current_member) notifications_to_mark_as_read.update_all(read_at: Time.zone.now) end end
This snippet of code does not seem to be working. I had thought that it should be modified to be @commentable, but when I tried that I got a no method error. As it stands, when I click on a notification it is running an UPDATE "notifications" SET "read_at" in the rails server output, so it looks like it should be working, but when I look in irb, read_at is still nil for the notification. I have posted the full question on stackoverflow here: https://stackoverflow.com/questions/75914440/rails-notifications-with-noticed-gem-not-getting-marked-as-read-on-polymorphic-c .I have not received any responses, so I'm kind of out of ideas at the moment. No google searches I've done have provided results for using the noticed gem with polymorphic entities. So, if you have any ideas of what I should try, then I would be really thankful. Thank you so much for your great gem. Please let me know if there is any more info I can provide to help find an answer.
Beta Was this translation helpful? Give feedback.
All reactions