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

Avoid unnecessary sql execution#974

Open
inkstak wants to merge 3 commits intoryanb:masterfrom
inkstak:master
Open

Avoid unnecessary sql execution#974
inkstak wants to merge 3 commits intoryanb:masterfrom
inkstak:master

Conversation

@inkstak
Copy link
Copy Markdown

@inkstak inkstak commented Dec 12, 2013

Hi,

When I'm using the :through option, in a load_and_authorize_resource, with ActiveRecord 3, I can see unexpected SQL queries in my log tail.

load_and_authorize_resource :ufo, through: :mothership

It seems to come from resource_base.respond_to?(:accessible_by).

You can try in a rails console :
mothership.ufos.respond_to?(:accessible_by)
=> # fire the SQL query and load all ufos

mothership.ufos.scoped.respond_to?(:accessible_by)
=> # wont fire anything

However, it works well with AR 4.

@rposborne
Copy link
Copy Markdown

+1

@matt-glover
Copy link
Copy Markdown

Related #398 and all of the associated 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

Successfully merging this pull request may close these issues.

3 participants