-
-
Notifications
You must be signed in to change notification settings - Fork 641
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
STI ability overwrites previously defined STI rules #874
Comments
I looked into this issue today, and it's a big rabbit hole 😅 I think there are 2 places which do not consider STI, and they are important when using accessible_by
I think the rules' subjects need to be normalized in some way so the rules on STI classes can be handled better |
Cool, thanks for looking into it. I'm not super deep into CanCanCan, but let me know if I can be of any help |
Me, neither, lol. I tried to solve the simpler issue first for STI. #877 but seem like it will be a very long waiting time before it gets merge (because they're too busy). After it's merged, I have an idea how to solve this issue 😁 |
Steps to reproduce
The order of
can
statements affects the SQL that is generated:Expected behavior
When using
Vehicle.accessible_by(ability, :index)
I would expect to have access to all vehicles, the generated SQL produces anOR
statement in cancancan 3.5.0 but truncates the statement to only include the last definedcan :index, XXXX
rule.Actual behavior
Demonstrated best by looking at the SQL:
Switching the order of the can statements:
IMO it should not matter, in which order the can statements are written.
System configuration
Rails version: Tested in 7.1 and 7.2
Ruby version: 3.3.3
CanCanCan version 3.6.1
The text was updated successfully, but these errors were encountered: