You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.
I'm using cancan with active_admin. It doesn't work as expected.
when I go to [admin]/clients, I got this exception: undefined method id' for #<ActiveRecord::Associations::CollectionProxy::ActiveRecord_Associations_CollectionProxy_User:0x007fc808c9cfc0>
@amrnt For some reason you're not getting a single user, but a collection of users. Just from this code I cannot tell you why.
The quick fix would be to rename user to users and doing users.first.id. You might want to dig deeper and try to understand why you're getting a collection, though.
PS: ActiveAdmin works reasonably well with CanCan, so if it is due to the integration of the two, it's probably something you're doing wrong.
Here's my models
in user model
in client model
membership model
my ability definition (for normal users)
I'm using cancan with active_admin. It doesn't work as expected.
when I go to
[admin]/clients
, I got this exception:undefined method id' for #<ActiveRecord::Associations::CollectionProxy::ActiveRecord_Associations_CollectionProxy_User:0x007fc808c9cfc0>
digging inside the code, on https://github.com/ryanb/cancan/blob/master/lib/cancan/rule.rb#L112
subject is an array of
User
records and name is the :idAm I doing something wrong? or there's a bug?
The text was updated successfully, but these errors were encountered: