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

load_resource with nested resource loads all records #398

@gucki

Description

@gucki

Using rails 3.1.0.rc4 and cancan 1.6.5. My controller contains a simple

load_resource :customer, :through => :current_account

When I now visit the index action (has a raise "test" in it so it does nothing), I see in my rails sql log:

User Load (0.7ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Account Load (0.2ms)  SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" = $1 LIMIT 1  [["id", "17"]]
Customer Load (27.0ms)  SELECT "customers".* FROM "customers" WHERE "customers"."account_id" = 17

As you can see the it loads all customers of the current account, which is really bad for performance. Shouldn't it by default load anything but only create a scope and store this in @customers?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions