Allow can with query on single resource - #785
Open
kaspernj wants to merge 5 commits into
Open
Conversation
kaspernj
force-pushed
the
allow-can-on-single-resource
branch
from
May 3, 2022 13:25
ebf633e to
02f63ac
Compare
kaspernj
commented
May 3, 2022
Contributor
Author
|
Did anyone have time to take a look at this? :-) |
coorasse
requested changes
Jul 6, 2022
| selects = query.values[:select] | ||
|
|
||
| if selects&.length != 1 | ||
| raise "Only one column should be selected and not #{selects&.length || 0} for: #{value.to_sql}" |
Member
There was a problem hiding this comment.
can you please add a test for this error?
Contributor
Author
There was a problem hiding this comment.
@coorasse I have added a test and fixed the issue with the wrong variable name :-)
Contributor
Author
|
@coorasse I feel like fixing the offence would require me to do an unrelated big refactor to CanCan::ConditionsMatcher. How would you prefer I continue? :-) |
garrettblehm
reviewed
Dec 1, 2025
garrettblehm
left a comment
There was a problem hiding this comment.
I would love to have this pushed through
Comment on lines
+91
to
+94
| if defined?(ActiveRecord) && | ||
| (value.is_a?(ActiveRecord::AssociationRelation) || value.is_a?(ActiveRecord::Relation)) | ||
| return condition_match_query?(attribute, value) | ||
| end |
There was a problem hiding this comment.
I think this could be moved within the case statement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Passing a query to a rule is already supported by
accessible_bybut not when checking on a single resource. This PR fixes that and adds specs for it.Example usage: