Comments (13)
I encountered a similar issue with v0.6.6 when deploying app to Heroku (but could not reproduce locally).
from action_policy.
Updated the title and details to single out eager loading as the setting that triggers this issue.
The cache_classes
setting is irrelevant in terms of this bug.
from action_policy.
This is a different error, but I believe is the same issue.
Here's a mostly minimal repo: https://github.com/t27duck/action_policy_eager_load
Check out, bundle install
, and rails c
should fail.
This is a vanilla rails app (minus action cable) with 0.6.6 installed with a single policy. The policy only has relation_scope
in it. In development.rb
the only change is setting eager_load
to true.
Full stacktrace:
➜ action_policy_eager_load git:(main) rails c
/Users/tdrake/workbench/action_policy_eager_load/app/policies/some_policy.rb:2:in `<class:SomePolicy>': undefined method `relation_scope' for SomePolicy:Class (NoMethodError)
from /Users/tdrake/workbench/action_policy_eager_load/app/policies/some_policy.rb:1:in `<main>'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/kernel.rb:30:in `require'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/helpers.rb:135:in `const_get'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/helpers.rb:135:in `cget'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/eager_load.rb:175:in `block in actual_eager_load_dir'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/helpers.rb:40:in `block in ls'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/helpers.rb:25:in `each'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/helpers.rb:25:in `ls'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/eager_load.rb:170:in `actual_eager_load_dir'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/eager_load.rb:17:in `block (2 levels) in eager_load'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/eager_load.rb:16:in `each'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/eager_load.rb:16:in `block in eager_load'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/eager_load.rb:10:in `synchronize'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/eager_load.rb:10:in `eager_load'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader.rb:379:in `block in eager_load_all'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader.rb:377:in `each'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader.rb:377:in `eager_load_all'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/application/finisher.rb:74:in `block in <module:Finisher>'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/initializable.rb:32:in `instance_exec'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/initializable.rb:32:in `run'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/initializable.rb:61:in `block in run_initializers'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/3.0.0/tsort.rb:228:in `block in tsort_each'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/3.0.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/3.0.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/3.0.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/3.0.0/tsort.rb:347:in `each'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/3.0.0/tsort.rb:347:in `call'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/3.0.0/tsort.rb:347:in `each_strongly_connected_component'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/3.0.0/tsort.rb:226:in `tsort_each'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/3.0.0/tsort.rb:205:in `tsort_each'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/initializable.rb:60:in `run_initializers'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/application.rb:372:in `initialize!'
from /Users/tdrake/workbench/action_policy_eager_load/config/environment.rb:5:in `<main>'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/kernel.rb:38:in `require'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/application.rb:348:in `require_environment!'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/command/actions.rb:28:in `require_environment!'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/commands/console/console_command.rb:105:in `perform'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/thor-1.2.2/lib/thor/command.rb:27:in `run'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/thor-1.2.2/lib/thor.rb:392:in `dispatch'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/command/base.rb:87:in `perform'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/command.rb:48:in `invoke'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/commands.rb:18:in `<main>'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from bin/rails:4:in `<main>'
Setting eager_load
to false does not invoke this exception.
from action_policy.
Also verified that 0.6.5 does not have this issue.
I have not disected anything, but my guess is this one did it:
from action_policy.
Just YOLO-ed a production app deploy that broke with 0.6.6 and pointed it to master
. Restarts and runs just fine with this change.
from action_policy.
thanks so much @palkan and @t27duck and everyone else. Really appreciate the speedy fix.
@palkan - apologies that I wasn't able to effectively replicate the problem. Thank you again for all these amazing gems. Your work has made a materially positive difference to my team's ability to ship useful code in record time. ❤️
from action_policy.
I'm seeing the same issue as well.
from action_policy.
I encountered a similar issue with v0.6.6 when deploying app to Heroku (but could not reproduce locally).
Try setting config/environments/development.rb
's config.eager_load
to true
and see if that reproduces the issue locally for you when trying to start your rails server?
from action_policy.
Hmmm ... I couldn't reproduce with that setting change.
from action_policy.
@t27duck Thanks a lot for the reproduction! Checking right now
from action_policy.
Fixed in master. I'd appreciate If anyone has a chance to check the fix against the real app. In any case, will publish a new release in the end of the day.
from action_policy.
Verified master
works with the minimal repo.
I switched eager_load
to true in dev mode for a production app locally which fails to run rails c
on 0.6.6 and switched the gem to master
. It appears to boot properly now too.
from action_policy.
Thanks!
Released in 0.6.7.
from action_policy.
Related Issues (20)
- Need help decoupling a policy from a controller
- feat: pass with: as string or symbol to perform policy lookup that respects the current namespace HOT 2
- Class based lookup with strict namespace and matching explicit namespace doesn't work HOT 2
- deprecation warning with Ruby 3.1 HOT 2
- Add option to disable authorization context memoization HOT 12
- Add ability to authorize nil records if :with option is provided HOT 2
- NoMethodError: undefined method `params_filter' for MyPolicy:Class in tests HOT 1
- Authorizing fields based on params_filter HOT 1
- Unknown policy scope type :active_record_relation HOT 3
- Policy-generator not working with Ruby 3.2 HOT 1
- uninitialized constant ActionController::Parameters HOT 4
- I18n does not seem to work with I18n Active Record HOT 1
- How Do I Test Resource-less Authorize? HOT 1
- Add --parent option to policy generator HOT 2
- Update a documentation about #be_an_alias_of matcher HOT 2
- Documentation Contrast HOT 3
- Can't alias `create?` to `manage?` HOT 1
- Cannot use `controller_authorize_current_user` with `ActionPolicy::Base` HOT 1
- 0.6.7 breaks wrap_parameters HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from action_policy.