ryanb/cancan — pull request #974 by inkstak (2013-12-12 08:01:22+00:00)
Title: Avoid unnecessary sql execution

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)`](https://github.com/ryanb/cancan/blob/master/lib/cancan/controller_resource.rb#L77).

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.