【问题标题】:undefined method `scope' for PaperTrail::VersionConcern:Module (NoMethodError)PaperTrail::VersionConcern:Module (NoMethodError) 的未定义方法“范围”
【发布时间】:2021-04-02 04:53:58
【问题描述】:

我的 gem 文件中有以下 gems

   gem 'paper_trail'
   gem 'paper_trail-association_tracking'

当我运行我的 Rails 服务器时,我收到错误“未定义的方法 `scope' for PaperTrail::VersionConcern:Module (NoMethodError)”

以下是完整的完整跟踪

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)

以下是版本详情

 ruby version: 2.7.2
 rails version 6.0.3.6

【问题讨论】:

  • 在将 paper_trail 12.0 与 paper_trail-association_tracking 结合使用时,看起来这是一个 issue

标签: ruby-on-rails paper-trail-gem


【解决方案1】:

在将 paper_trails 升级到版本 12 时遇到了这个问题。临时修复是降级到 11,同时他们在最新版本上修复了这个问题

【讨论】:

    【解决方案2】:

    我的建议是从您的 gem 文件中删除 paper_trail-association_tracking 并删除任何初始化程序和其他相关代码。欲了解更多信息,请参阅此链接https://github.com/paper-trail-gem/paper_trail/pull/1281

    【讨论】:

    • 你是真的,先安装paper_trail再安装paper_trail-association_tracking
    猜你喜欢
    • 2012-01-18
    • 1970-01-01
    • 2013-04-24
    • 2015-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-23
    • 2012-05-11
    相关资源
    最近更新 更多