ruby-on-railspaper-trail-gem

undefined method `scope' for PaperTrail::VersionConcern:Module (NoMethodError)


I have the following gems in my gem file

   gem 'paper_trail'
   gem 'paper_trail-association_tracking'

When I am running my rails server I am getting the error " undefined method `scope' for PaperTrail::VersionConcern:Module (NoMethodError)"

Below is the full the full trace

41: from bin/rails:4:in `<main>'
40: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
39: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
38: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
37: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
36: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
35: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/railties-6.0.3.6/lib/rails/commands.rb:18:in `<main>'
34: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/railties-6.0.3.6/lib/rails/command.rb:46:in `invoke'
33: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/railties-6.0.3.6/lib/rails/command/base.rb:69:in `perform'
32: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
31: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
30: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
29: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/railties-6.0.3.6/lib/rails/commands/server/server_command.rb:138:in `perform'
28: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/railties-6.0.3.6/lib/rails/commands/server/server_command.rb:138:in `tap'
27: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/railties-6.0.3.6/lib/rails/commands/server/server_command.rb:141:in `block in perform'
26: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/activesupport-6.0.3.6/lib/active_support/dependencies.rb:324:in `require'
25: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/activesupport-6.0.3.6/lib/active_support/dependencies.rb:291:in `load_dependency'
24: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/activesupport-6.0.3.6/lib/active_support/dependencies.rb:324:in `block in require'
23: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
22: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
21: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
20: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
19: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
18: from /Users/devi/Desktop/all_projects/zensuper/zen_super_admin/config/application.rb:8:in `<main>'
17: from /Users/devi/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler.rb:174:in `require'
16: from /Users/devi/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:58:in `require'
15: from /Users/devi/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:58:in `each'
14: from /Users/devi/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:69:in `block in require'
13: from /Users/devi/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:69:in `each'
12: from /Users/devi/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:74:in `block (2 levels) in require'
11: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
10: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
 9: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
 8: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
 7: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
 6: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/paper_trail-association_tracking-2.1.1/lib/paper_trail-association_tracking.rb:22:in `<main>'
 5: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/paper_trail-association_tracking-2.1.1/lib/paper_trail-association_tracking.rb:51:in `<module:PaperTrail>'
 4: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/paper_trail-association_tracking-2.1.1/lib/paper_trail-association_tracking.rb:52:in `<module:VersionConcern>'
 3: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/paper_trail-association_tracking-2.1.1/lib/paper_trail-association_tracking.rb:52:in `include'
 2: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/activesupport-6.0.3.6/lib/active_support/concern.rb:122:in `append_features'
 1: from /Users/devi/.rvm/gems/ruby-2.7.2/gems/activesupport-6.0.3.6/lib/active_support/concern.rb:122:in `class_eval'
 /Users/devi/.rvm/gems/ruby-2.7.2/gems/paper_trail-association_tracking-2.1.1/lib/paper_trail_association_tracking/version_concern.rb:19:in `block in <module:VersionConcern>': undefined method `scope' for PaperTrail::VersionConcern:Module (NoMethodError)

Following are the version details

 ruby version: 2.7.2
 rails version 6.0.3.6

Solution

  • My suggestion is to remove paper_trail-association_tracking from your gem file and remove any initializer and other related code. For more info refer this link https://github.com/paper-trail-gem/paper_trail/pull/1281