DEV Community


Discussion on: Why is Rails ActiveRelation.update_all updating a different set of records?

andy profile image
Andy Zhao (he/him) Author

You're totally right about not being able to call .where on comment; the example I used is wrong. I'm actually doing this:

comment.subtree.union(comment.ancestors).where(user_id: comment.user_id)

.subtree and .ancestors are methods from a gem, and I initially thought putting that in the example would be confusing. My workaround-example made it more confusing. 🙃