Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Calling respond_to? when loading collection through association causes full load of associated records #729

Open
pdf opened this issue Aug 26, 2012 · 2 comments

Comments

@pdf
Copy link

pdf commented Aug 26, 2012

In ActiveRecord::Associations::CollectionProxy, a call to respond_to? triggers load_target before checking the proxy_association class, which in turn calls .all on the association, forcing immediate load of all records. In my application this is causing the early load of millions of records, since scopes have not yet been applied.

@pdf
Copy link
Author

pdf commented Aug 26, 2012

Attached is a suggestion for fixing this on AR, for master and 2.0 branches. No specs included, not sure how best to go about testing it...

pdf added a commit to pdf/cancan that referenced this issue May 5, 2013
pdf added a commit to pdf/cancan that referenced this issue May 5, 2013
pdf added a commit to pdf/cancan that referenced this issue May 5, 2013
@matt-glover
Copy link

See also #398 and linked issues

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants