对嵌套关注点的循环依赖

2023-12-31

有人知道为什么在我的生产服务器上我不能在模型中使用嵌套关注点吗?

我有一个模型Landing

class Landing < ActiveRecord::Base

  include Claimable

end

和关心

module Claimable
  extend ActiveSupport::Concern

end

一切工作正常,但 Claimable 是严格的着陆逻辑,所以我想将其放入嵌套路线

class Landing < ActiveRecord::Base

  include Landing::Claimable

end

and

 module Landing::Claimable
  extend ActiveSupport::Concern

end

这在我的开发机器(OS X Yosemite)上运行,但是当我部署到 Linux 生产服务器时,我收到错误:

/home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:492:in `load_missing_constant': Circular dependency detected while autoloading constant Landing::Claimable (RuntimeError)
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:184:in `const_missing'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/app/models/landing.rb:20:in `<class:Landing>'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/app/models/landing.rb:18:in `<top (required)>'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:360:in `require_or_load'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:494:in `load_missing_constant'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:184:in `const_missing'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/app/models/concerns/landing/claimable.rb:1:in `<top (required)>'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:360:in `require_or_load'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:317:in `depend_on'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:233:in `require_dependency'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:472:in `block (2 levels) in eager_load!'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:471:in `each'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:471:in `block in eager_load!'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:469:in `each'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:469:in `eager_load!'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:346:in `eager_load!'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/application/finisher.rb:56:in `each'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `instance_exec'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `run'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:55:in `block in run_initializers'
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each'
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `call'
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:54:in `run_initializers'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/railties-4.2.0/lib/rails/application.rb:352:in `initialize!'
from /home/app/app/current/config/environment.rb:5:in `<top (required)>'
from /home/app/app/current/config.ru:3:in `require'
from /home/app/app/current/config.ru:3:in `block in <main>'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `instance_eval'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `initialize'
from /home/app/app/current/config.ru:1:in `new'
from /home/app/app/current/config.ru:1:in `<main>'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/rack/adapter/loader.rb:33:in `eval'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/rack/adapter/loader.rb:33:in `load'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/rack/adapter/loader.rb:42:in `for'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/controllers/controller.rb:170:in `load_adapter'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/controllers/controller.rb:74:in `start'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/runner.rb:200:in `run_command'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/lib/thin/runner.rb:156:in `run!'
from /home/app/app/releases/a34cd4a786d8f6c35179fb8eebc34469f471192a/vendor/bundle/ruby/2.1.0/gems/thin-1.6.3/bin/thin:6:in `<top (required)>'
from /home/app/app/releases/68f6492bb01f28373b95f26f34b609fdb99dc9cd/vendor/bundle/bin/thin:16:in `load'
from /home/app/app/releases/68f6492bb01f28373b95f26f34b609fdb99dc9cd/vendor/bundle/bin/thin:16:in `<main>'

这通常与您的config.eager_load您的应用程序上的设置。您在生产环境中的设置与开发环境中的设置不同,这是完全正常的且符合预期用途,但这就是为什么您会在从开发到生产的过程中经历不同的行为。

作为一种可能的解决方案,我建议您避免使用单行命名空间类定义,并将其更改为多行。

尝试改变:

module Landing::Claimable
end

to:

module Landing
  module Claimable
  end
end
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

对嵌套关注点的循环依赖 的相关文章

  • Rails 4、omniauth-facebook、rack-cors、Heroku 的 CORS 问题

    Summary 我有 CORS 问题 我正在尝试使用 Rails API 从 React 应用程序向 Facebook 进行身份验证 我的应用程序在 localhost 8080 上运行 我的 api 在 Heroku 上运行 我可以登录
  • Rails ActiveRecord 按日期将结果分组到子集合中

    我正在尝试在 Rails 3 1 中执行 ActiveRecord 查询 其中我将结果排序到分组项目的子集合中 在本例中按日期分组 我认为我的代码可以最好地解释它 这是我的方法 它有效 但发出 4 个查询才能完成工作 这样做似乎效率不太高
  • RSpec:如何创建辅助存根方法?

    我正在尝试从我的助手中存根一个助手方法 sessions helper rb require rest client module SessionsHelper BASE URL http localhost 1234 def curren
  • Rails Heroku 服务器回形针 Amazon S3 - AWS::S3::Errors::RequestTimeout

    当我使用附加图像保存 konkurrencer 模型时 我在 Heroku 上收到错误 但在本地服务器上却没有 我的 Heroku 日志 36m2012 04 01T17 45 37 00 00 app web 1 0m Started P
  • Capistrano RVM 和 Ubuntu RVM 不是一个函数,使用“rvm use ...”选择 rubies 将不起作用

    我第一次尝试在 ubuntu 服务器上部署我的应用程序 我一直遇到这个错误 2013 03 24 15 13 36 executing deploy run migrations executing rvm gemset use vapin
  • 使 diff-lcs 的输出可读

    我正在使用 diff lcs gem 输出两个 html 内容体之间的差异 这是示例内容 版本一 p Paragraph one Sentence one p p Paragraph two Another sentence p p Par
  • 在虾中使用列表

    我使用 prawn 创建 pdf 文件 其中包含大量表格格式的数据和一些列表 列表的问题在于 我只是使用文本作为列表 因为没有与 ul gt li 列表等效的语义 就像我在 webfrointend 中使用它们一样 所以这些清单是不合理的
  • 如何将 image_tag 与 bootstrap class: "img-responsive" 一起使用?第11章

    我问这个问题的原因是为了解决一个非常烦人的语法错误 我正在使用第 11 章 这样我就可以在我的新网站上使用图像构建一个博客部分 除了我尝试向此行添加 class img responsive 之外 一切都正常 我只是无法弄清楚添加类的正确语
  • Rails 如何确定传入请求格式?

    我只是想知道 Rails 如何知道请求的格式以正确输入著名的 respond to do format format html format xml format json end 作为一个例子 考虑一下我遇到的这种情况 假设通过 java
  • ruby 无法复制 Fixnum

    我有一些这样的代码 ssh files id rsa pub id rsa ssh files each with index do item index ssh files index generate ssh path creator
  • Friendly_id 和真实ID

    有什么办法可以得到真正的id使用Friendly id 修改的模型中的列 出于性能原因 我不想对其进行另一个数据库查询 广义上来说Friendly id修改to param and find方法 接下来应该可以工作 affiche Affi
  • 如何在Rails中显示URL指向的图像

    我这里有一张图片http power itp ac cn jmyang funny fun4 jpg http power itp ac cn jmyang funny fun4 jpg我想在我的 Rails 站点中显示它 我该怎么做 您还
  • 在environment.rb中设置的常量在开发模式下消失

    了解 Rails 缓存如何工作的人可以真正帮助我 这是嵌套在 Rails Initializer run 块内的代码 config after initialize do SomeClass const set SOME CONST SOM
  • 安装heroku toolbelt后出现Ruby错误

    我正在 win 7 32 位系统上使用 Heroku 但我没有管理员权限 我已经下载并安装了heroku工具带如下http community webfaction com questions 11803 heroku toolbelt h
  • 安装 mysql2 时出错:无法构建 gem 本机扩展

    我在尝试安装时遇到一些问题mysql2Rails 的宝石 当我尝试通过运行安装它时bundle install or gem install mysql2它给了我以下错误 安装 mysql2 时出错 错误 无法构建 gem 本机扩展 我该如
  • 是否仍然可以在 Rails 4 中使用测试单元?

    从 Rails 3 2 升级到 Rails 4 后 我的应用程序可以运行 但我用测试单元编写的测试是一场灾难 据传 Minitest 与测试单元 兼容 然而 如果我尝试使用 现在捆绑的 Minitest 就会发现有很多差异 从断言 语句名称
  • 在 Rails 中,如何创建用户组作为另一个关联,例如“成员”?

    我正在尝试在两个现有模型之间创建特殊关系 User and Dwelling A Dwelling只有一个所有者 Dwelling belongs to user User has one dwelling 在创建时 但其他用户可以添加到此
  • 如何在 Rails 中对不同用户建模

    Question 我有一个带有内置授权和身份验证逻辑的用户模型 现在我意识到我拥有三种不同类型的用户 我想存储每个人的不同信息 Rails 中处理这个问题的最佳方法是什么 基于当前阅读的想法 我看过 STI 但从我读到的内容来看 它是不合适
  • 哈米尔评论结束

    我是哈米尔新手 这让我很困惑 我不喜欢删除可以注释掉的代码 但我不知道如何在 haml 中正确结束注释 这是一个代码片段 field f label member id br f text field member id field f l
  • 安装适用于 Windows 7 的 Ruby on Rails(最新)

    我是一名设计师 而不是一名编码员 并且在首次安装时遇到了问题 我下载了 Rails 1 8 6 和 Instant Rails 我打开控制台并尝试更新 gem 那里没有任何作用 我想我会删除所有内容并重新开始 因为我确信我现在破坏了某些东西

随机推荐