You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then the view duplicates each foo by the number of cars they have in the :through ownership association - so if auser.foos.first has 3 cars. foos.first will be iterated through 3 times in the paginated view.
Not 100% sure of where the issue is, but it seems to come up with has_many associations.
If I have a scope in a Foo model (where a user has_many: foos) - models/foo.rb:
And now try use the scope with will_paginate (in the controller):
Then the view duplicates each foo by the number of cars they have in the :through ownership association - so if
auser.foos.first
has 3 cars.foos.first
will be iterated through 3 times in the paginated view.I can work around this by using a group:
http://stackoverflow.com/questions/38671915/rails-will-paginate-with-named-scope-for-associations-0/38671965#38671965
http://stackoverflow.com/questions/11729816/rails-will-paginate-shows-duplicates-on-habtm-models
The text was updated successfully, but these errors were encountered: