Upgrade from cancan 1.6.9 to cancancan

46 views
Skip to first unread message

freema...@gmail.com

unread,
Nov 30, 2014, 7:08:50 PM11/30/14
to canc...@googlegroups.com
I use cancan 1.6.9 with rails 3.2. I want to upgrade to cancancan.
According to semver I can simply replace "cancan" in Gemfile by "cancancan".

But the thing is that there is some weird issue with that.
If I have some conditions on cancan rule like this:
can [:index], User, city: { id: [1,2,3] }
In cancan I get appropriate scope for my loaded resources in UsersController before the index action so I have such SQL:

def index
puts @users.to_sql
end

=> "SELECT \"users\".* FROM \"users\" WHERE \"cities\".\"id\" IN (1,2,3)"

But in cancancan the output is different

=> "SELECT \"users\".* FROM \"users\"


Seems like the scope got applied after the action or something like that.

Is it expected behaviour? Maybe there are some special things that I need to know when upgrading from cancan 1.6.9 to cancancan 1.9.2 (latest version at the moment)?

Thanks

brite

unread,
Dec 1, 2014, 5:17:22 AM12/1/14
to canc...@googlegroups.com, freema...@gmail.com
There definitely shouldn't be a problem with what you're doing here, cancancan is backwards compatible with cancan (or should be!).

At first glance... is cities an associated model of User? There should be an inner join in there...

Could you post more of your controller and applicable model parts, or preferably, a minimal rails app example?
Reply all
Reply to author
Forward
0 new messages