plots2
plots2 copied to clipboard
NoMethodError: undefined method `notes_for_tags' for #<User:0x00007f95d21db590>
Sentry Issue: PLOTS2-18A
NoMethodError: undefined method `notes_for_tags' for #<User:0x00007f95d21db590>
Did you mean? note_streak
app/controllers/notes_controller.rb:336:in `author_topic'
@notes = @user.notes_for_tags(@tagnames)
...
(104 additional frame(s) were not displayed)
Affecting pages like https://publiclab.org/notes/author/kanarinka/water-quality-monitoring
We should perhaps also ensure we have a functional test for this page!
Also affecting: https://publiclab.org/notes/author/Sara/events:boston
That's line 336 -
https://github.com/publiclab/plots2/blob/1afcac6d61715fcd346e3b7148a7505697297ca1/app/controllers/notes_controller.rb#L331-L339
I don't know when this method was deleted, but it's nowhere to be found now! Let's just refactor -- we need a query that fetches notes tagged with the given tag, but only by that author.
Probably something like:
nids = NodeTag.includes(:node, :tag)
.references(:term_data)
.where(type: 'note')
.where(name: tagnames, uid: :uid)
@pagy, @notes = pagy(Node
.order('nid DESC')
.where(nid: nids), items: 24)
@Manasa2850 @17sushmita this is a small but kind of interesting one related to tagging! Would either of you be interested?
can you explain me the issue a bit more? @TildaDares
@Ash-KODES The reason for the error is because the notes_for_tags method is missing from the User model. What you need to do is create the notes_for_tags method in user.rb. The method will be something like:
Probably something like:
nids = NodeTag.includes(:node, :tag) .references(:term_data) .where(type: 'note') .where(name: tagnames, uid: :uid) @pagy, @notes = pagy(Node .order('nid DESC') .where(nid: nids), items: 24)
A few things will have to change like removing the @pagy and pagy variables/method call. I hope that helps.
Hey @TildaDares, can I take up this issue?
Hi @KarishmaVanwari, go ahead! Thank you.
Hey @TildaDares, I've opened a PR #10801. Please have a look. Thanks!
Hey @TildaDares! Hope you are doing well.
Was this issue ever resolved or can I pick it up?
Hi @toshitapandey, please go ahead. Thank you!