ryanb/cancan — Issue #574: cancanc is not picking the correct field when parent and child models share name.
Author: c4ftabrez
Created: 2012-03-08 03:49:31+00:00
State: open

Hi,
In Issue #102 you have indicated that we can use attributes from a parent model in the following way:

```
can :manage, TakeActionNote, :take_action => { :user_id => user.id }
```

I have a similar situation. The problem is that both models have a user_id column. Despite providing the hash conditions as above, the generated query is using the user_id from the child model.

```
SELECT "take_action_notes".* FROM "take_action_notes" INNER JOIN "take_actions" ON "take_actions"."id" = "take_action_notes"."take_action_id" WHERE (("take_action_notes"."user_id" = 1)
```

I was expecting the query to have take_actions.user_id instead. Is this an issue due to some dynamic probing? Or, am I just doing something incorrectly?

I tried using a virtual attribute in the child model to get the parent model's user_id, to break the conflict. But that did not work as the hash expects column names.