Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Debugging Abilities on an instance #684

daveroberts opened this Issue · 8 comments

4 participants


I can get the SQL cancan uses with the following:


How can I get the SQL associated with the following?

ability.can?(:read, project)

From my limited knowledge of CanCan, accessible_by makes a db call where as can? just tries to determine from the defined rules if someone's got access or not. It doesn't make any db calls.

I could be totally wrong.


Thanks for the reply:

accessible_by is a method on the class only. There isn't a call for


Yeah, it's mixed as a class method in model class. Can you please tell us what you are trying to do and I could suggest a way to do it? Thanks.


We have a rule similar to the following:

can :read, [Class1,Class2], "class3_table_name.column" => user.some_property

We want to create a similar rule, but I'm not sure which tables are being included in the sql, or what the sql looks like, so I don't know what's available to me to construct the new rule.

class3 is an association that both class1 and class2 have, and I'm not sure how or when it's getting called from the SQL. I'd just like visibility into what the rule's doing, so I can understand how it's being used, and how to extend it.

I'm sorry I can't give more detailed information on this.


Tracing the can? method call here it doesn't appear to touch the db, it do all the checks only analyzing the defined rules

Can this issue be closed? /cc @daveroberts @ryanb


The code you linked to doesn't show how the extra args are handled. I find it hard to believe it's not touching the database in a sub call because of the way we currently have the extra args defined. I see that the DB isn't touched directly from the method that you link.


Well, you can do a proof checking in the log if the app is touching the DB when can? is called


Dear submitter, Since cancan/raynB hasn't been active for more than 6 months and no body else then ryam himself has commit permissions the cancan project is on a stand still.
Since cancan has several issues including missing support for rails 4 cancan is moving forward to cancancan. More details on: #994

If your feel that your pull request or bug is still applicable (and hasn't been merged in to cancan) it would be really appreciated if you would resubmit it to cancancan (

We hope to see you on the other side!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.