-
-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mark_as_unread!
does not work for association collections
#66
Comments
I think this is a bug. The concern should define |
Actually, seems to work without it. Added a test to confirm it was broken, but it passed. Must be because the module name matches what Concern looks for. |
Indeed. Perhaps it makes sense to add a corresponding method there to mark multiple notifications unread too? |
Like I mentioned, it's already there and has been for a while. https://github.com/excid3/noticed/blob/master/lib/noticed/model.rb#L18-L20 Here's the test I just added to confirm it works: 8f9d070 Your model includes the Noticed::Model module? |
Haha, yep, like I stated in the "Additional Information", The opposite function |
Ah! I read through too quickly. 😅 I blame it being Monday. I'll get that fixed shortly. |
Perfect, thank you! 👏 I suppose documenting methods for collections would be sweet as well. Might help out people who wouldn't test their luck out. |
Released as v1.2.20 Also added to the readme with the other methods: https://github.com/excid3/noticed#-database-model |
Hey, it seems that the mark_as_read! and mark_as_unread! methods no longer work for the association collections as of V2 with the new models. Is this intentional? |
@ykamin-booth is your association empty when you call it and get the error? Edit: Scratch that, it seems that the bang variant does not work but |
Adding that to the UPGRADE guide. Since they do not raise errors, we removed the |
Hey!
This gem is a blessing and saved so much time already. I ran into this obscure use case where I'd need to mark a bunch of notifications as unread and the gem doesn't seem to support it (yet). 🤷♂️
Gem version: 1.2.19
Expected Behavior
Running
user.notifications.mark_as_unread!
should mark the notification records as not read.Actual Behavior
Running
user.notifications.mark_as_unread!
throws anundefined method 'mark_as_unread!' for #<Notification::ActiveRecord_Associations_CollectionProxy:0x0000000000000>
error.Additional Information
user.notifications.mark_as_read!
works as one would expect.The text was updated successfully, but these errors were encountered: