Closed mogya closed 1 year ago
The same happens with simply using where
on a scope. A failing test:
countries = Country.where(language: "English")
expect(countries.size).to eq 2
expect(countries.where(name: "US").size).to eq 1 # ✅
expect(countries.size).to eq 2 # 🤯 fails as the previous line mutated the scope!
Fixed in #265
Thank you for helping us with this solution. Going with #268 instead
Define scope on ActiveHash class and calling it, seems polluting original object.
reproduce
expected behavior
c.count should returns 2 because ActiveRecord scope returns new relation and do not affect to self.
environment