narrow-magazine-18722
07/21/2023, 3:34 PMfield :posts, as: :has_many, through: :comments
and I appear to be getting the same Post
record in the list multiple times if there are multiple comments, can I dedupe this somehow?loud-jewelry-99127
07/21/2023, 5:26 PMruby
field :posts,
as: :has_many,
through: :comments,
scope: -> { query.distinct }
narrow-magazine-18722
07/21/2023, 5:26 PMloud-jewelry-99127
07/21/2023, 5:27 PMnarrow-magazine-18722
07/21/2023, 5:27 PMdistinct
is unwanted?loud-jewelry-99127
07/21/2023, 5:28 PMnarrow-magazine-18722
07/21/2023, 5:29 PMdistinct
won't surface a count, but to get a count that would require some more custom worknarrow-magazine-18722
07/21/2023, 5:29 PMnarrow-magazine-18722
07/21/2023, 5:31 PMloud-jewelry-99127
07/21/2023, 5:34 PMnarrow-magazine-18722
07/21/2023, 6:24 PMnarrow-magazine-18722
07/21/2023, 6:27 PMdistinct
worked perfectly for what I'm currently doing, thank you