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

accessible_by submodel #309

Closed
PHP-Point-Of-Sale opened this issue Mar 17, 2011 · 1 comment
Closed

accessible_by submodel #309

PHP-Point-Of-Sale opened this issue Mar 17, 2011 · 1 comment

Comments

@PHP-Point-Of-Sale
Copy link

What exactly happens in this scenario?

@patient.course_enrollments.accessible_by(current_ability)

It seems to do exactly what I want, but it is just crazy that it works

@ryanb
Copy link
Owner

ryanb commented Mar 18, 2011

What happens there depends on what you have in the Ability class. In a simple case, CanCan will just append a where clause to that passing in your hash conditions.

# in Ability
can :manage, CourseEnrollment, :enrolled => true

# does this
@patient.course_enrollments.where(:enrolled => true)

It does more complex things when a nested hash is provided because it needs to do a joins clause as well, but the behavior is similar.

@ryanb ryanb closed this as completed May 2, 2011
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant