We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
authorize!
Ruby Version: 2.7.3
Framework Version (Rails, whatever): Rails 6.1.3
Action Policy Version: 0.5.7
Reproduction Script: It's difficult to reproduce, but i've explained it below.
We have a setup similar to this:
class User < ApplicationRecord has_many :widgets end class WidgetsController < ApplicationController def index widgets = current_user.widgets authorize! widgets render locals: { widgets: paginate(widgets) } end end
authorize! widgets should not load the widgets AR relation.
authorize! widgets
widgets
Action Policy executes and loads all the records in widgets. This happens before pagination, so it causes performance problems.
This is because widgets is an ActiveRecord::AssociationRelation, and when ActionPolicy does widgets == :__undef__ as part of policy lookup, the #== method from AR executes the query.
ActiveRecord::AssociationRelation
widgets == :__undef__
#==
The text was updated successfully, but these errors were encountered:
fix: regression for implict record comparison
0b82b66
Ref #179
9512492
Successfully merging a pull request may close this issue.
Tell us about your environment
Ruby Version: 2.7.3
Framework Version (Rails, whatever): Rails 6.1.3
Action Policy Version: 0.5.7
Reproduction Script: It's difficult to reproduce, but i've explained it below.
What did you do?
We have a setup similar to this:
What did you expect to happen?
authorize! widgets
should not load thewidgets
AR relation.What actually happened?
Action Policy executes and loads all the records in
widgets
. This happens before pagination, so it causes performance problems.This is because
widgets
is anActiveRecord::AssociationRelation
, and when ActionPolicy doeswidgets == :__undef__
as part of policy lookup, the#==
method from AR executes the query.The text was updated successfully, but these errors were encountered: