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

Avoid unnecessary sql execution #974

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Avoid unnecessary sql execution #974

wants to merge 3 commits into from

Conversation

inkstak
Copy link

@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

+1

@matt-glover
Copy link

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