-
-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow can with query on single resource #785
base: develop
Are you sure you want to change the base?
Allow can with query on single resource #785
Conversation
ebf633e
to
02f63ac
Compare
Did anyone have time to take a look at this? :-) |
lib/cancan/conditions_matcher.rb
Outdated
selects = query.values[:select] | ||
|
||
if selects&.length != 1 | ||
raise "Only one column should be selected and not #{selects&.length || 0} for: #{value.to_sql}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please add a test for this error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coorasse I have added a test and fixed the issue with the wrong variable name :-)
Passing a query to a rule is already supported by
accessible_by
but not when checking on a single resource. This PR fixes that and adds specs for it.Example usage: