Rails 7
See original GitHub issueIssue Description
Hi,
I am trying to update to Rails 7 and I got an error with Effective Datatables.
➜ coku-app git:(master) ✗ rspec spec/interactors/company/create_spec.rb
An error occurred while loading rails_helper.
Failure/Error: require File.expand_path('../../config/environment', __FILE__)
NameError:
uninitialized constant EffectiveDatatables::Engine::EffectiveDatatablesHelper
# /Users/Nerian/projects/effective_datatables/lib/effective_datatables/engine.rb:10:in `block (2 levels) in <class:Engine>'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:71:in `class_eval'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:51:in `each'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/actionpack-7.0.0/lib/action_controller/base.rb:270:in `<class:Base>'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/actionpack-7.0.0/lib/action_controller/base.rb:166:in `<module:ActionController>'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/actionpack-7.0.0/lib/action_controller/base.rb:7:in `<top (required)>'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/zeitwerk-2.5.2/lib/zeitwerk/kernel.rb:36:in `require'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/actionpack-7.0.0/lib/action_controller/railtie.rb:81:in `block (3 levels) in <class:Railtie>'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/actionpack-7.0.0/lib/action_controller/railtie.rb:77:in `each'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/actionpack-7.0.0/lib/action_controller/railtie.rb:77:in `block (2 levels) in <class:Railtie>'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:71:in `class_eval'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:51:in `each'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/actionpack-7.0.0/lib/action_controller/api.rb:148:in `<class:API>'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/actionpack-7.0.0/lib/action_controller/api.rb:89:in `<module:ActionController>'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/actionpack-7.0.0/lib/action_controller/api.rb:7:in `<top (required)>'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/zeitwerk-2.5.2/lib/zeitwerk/kernel.rb:36:in `require'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/sorcery-0.16.2/lib/sorcery/engine.rb:16:in `block in <class:Engine>'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/railties-7.0.0/lib/rails/initializable.rb:32:in `instance_exec'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/railties-7.0.0/lib/rails/initializable.rb:32:in `run'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/railties-7.0.0/lib/rails/initializable.rb:61:in `block in run_initializers'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/railties-7.0.0/lib/rails/initializable.rb:60:in `run_initializers'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/railties-7.0.0/lib/rails/application.rb:369:in `initialize!'
# ./config/environment.rb:5:in `<top (required)>'
# ./spec/rails_helper.rb:9:in `require'
# ./spec/rails_helper.rb:9:in `<top (required)>'
This originates from here: https://github.com/code-and-effect/effective_datatables/blob/master/lib/effective_datatables/engine.rb#L10
Looks like Zeitwerk is not able to find the helper.
I tried commenting the code for both initializers in that file just to see what else happens, and it got a similar error for EffectiveResources:
➜ coku-app git:(master) ✗ rspec spec/interactors/company/create_spec.rb
An error occurred while loading rails_helper.
Failure/Error: require File.expand_path('../../config/environment', __FILE__)
NameError:
uninitialized constant EffectiveResources::Engine::ActsAsArchived
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/effective_resources-1.9.12/lib/effective_resources/engine.rb:25:in `block (2 levels) in <class:Engine>'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:71:in `class_eval'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:43:in `block in on_load'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:42:in `each'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/activesupport-7.0.0/lib/active_support/lazy_load_hooks.rb:42:in `on_load'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/effective_resources-1.9.12/lib/effective_resources/engine.rb:24:in `block in <class:Engine>'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/railties-7.0.0/lib/rails/initializable.rb:32:in `instance_exec'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/railties-7.0.0/lib/rails/initializable.rb:32:in `run'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/railties-7.0.0/lib/rails/initializable.rb:61:in `block in run_initializers'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/railties-7.0.0/lib/rails/initializable.rb:60:in `run_initializers'
# /Users/Nerian/.rvm/gems/ruby-2.7.5/gems/railties-7.0.0/lib/rails/application.rb:369:in `initialize!'
# ./config/environment.rb:5:in `<top (required)>'
# ./spec/rails_helper.rb:9:in `require'
# ./spec/rails_helper.rb:9:in `<top (required)>'
Looks like the gems are not following zeitwerk naming conventions. It is strange that it just began failing in Rails 7, since I have zeitwerk activated in Rails 6 too 🤔 Any ideas?
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Rails 7.0: Fulfilling a vision - Ruby on Rails
This version of Rails has been years in the conceptual making. It's the fulfillment of a vision to present a truly full-stack approach...
Read more >Ruby on Rails 7.0 Release Notes
Ruby on Rails 7.0 Release Notes · 1 Upgrading to Rails 7.0 · 2 Major Features · 3 Railties · 4 Action Cable...
Read more >Rails 7.0.4, 6.1.7, and 6.0.6 have been released!
I am happy to announce that Rails 7.0.4, 6.1.7, and 6.0.6 have been released. These fixes are bugfix releases with various enhancements, ...
Read more >Ruby on Rails — A web-app framework that includes ...
A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.
Read more >Ruby on Rails Guides
These are the new guides for Rails 7.0 based on v7.0.4. These guides are designed to make you immediately productive with Rails, and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Not speaking for @matt-riemer but imo we won’t be exploring support for Rails 7 in effective_datatables until after 7.1 is released. This is because we typically follow a major version behind latest Rails. This might get looked at when we do an upgrade to Bootstrap 5, which is hopefully in Q1 2022, but that work isn’t locked in our schedule yet.
Pretty sure the problem is the engine initializer.
The syntax kind of changed between rails versions. Gotta use that
app.config.to_prepare
block in newer apps instead of the oldActiveSupport.on_load
https://github.com/code-and-effect/effective_datatables/blob/master/lib/effective_datatables/engine.rb
Just copy & pasting the current master version of this engine.rb over the 3.0.x branch might work and be all the changes required for rails 7! Might be another gotcha or two.