草庐IT

dependent-destroy

全部标签

ruby - 运行时错误 : Circular dependency detected while autoloading constant

我通过引入请求和响应模型来重构我的Controller,以执行此presentation之后Controller周围的一些逻辑。.我分别用模块Responses和Requests包装了所有的响应和请求模型。应用程序运行完美,但当我运行测试时,出现以下错误。Failure/Error:UnabletofindmatchinglinefrombacktraceRuntimeError:CirculardependencydetectedwhileautoloadingconstantResponses::FolderContentResponse我的目录结构如下:-应用/-模型/-回应/注

ruby-on-rails - Controller : Circular dependency detected while autoloading constant 中的 Rails 4 运行时错误

如果我遗漏了什么,请告诉我。我不明白为什么无法访问我的views/references/文件夹。new.html.erb和index.html.erb都不可用。当我转到localhost:3000/references时,我的错误是:RuntimeErrorinReferencesController#indexCirculardependencydetectedwhileautoloadingconstantReferencesController我相信这是设置,它不应该是Rails问题,因为我的其他Controller工作正常。我的路线文件中有resources:reference

ruby-on-rails - 回形针 :style depending on model (has_many polymorphic images)

我已将我的模型设置为使用多态图像模型。这工作正常,但我想知道是否可以更改每个模型的:styles设置。找到了一些使用STI(Model艺术has_many:images,:as=>:imageable图片belongs_to:imageable,:polymorphic=>truehas_attached_file:file,:styles=>{:thumb=>"150x150>",:normal=>"492x600>"}#Changethissettingdependingonmodel更新我尝试在Proc方法中启动调试器。仅填充与附件相关的字段:run'irb(Image):006

ruby-on-rails - 对于 Ruby, "gem install"是否使用 "--include-dependencies"...只是文档有点过时了?

使用RubyonRails,如果我做一个gemhelpinstall它的一部分说:-y,--include-dependenciesUnconditionallyinstalltherequireddependentgems[...]Defaults:--both--version'>=0'--rdoc--ri--no-force--no-test--install-dirc:/ruby/lib/ruby/gems/1.8但是如果我做一个geminstall--include-dependenciesmysql一行说:INFO:`geminstall-y`isnowdefaultand

ruby-on-rails - 我将如何 destroy_all 或 delete_all 记录,除了 ruby​​ on rails 中的一条记录?

我在我的网站上为我的用户消息线程功能使用“acts_as_tree”插件。我有一种方法可以删除选定的消息。这些消息实际上并没有被删除。它们的sender_status或recipient_status列设置为1,具体取决于邮件的发件人或收件人是哪个用户。无论如何,如果两个用户都将这些状态设置为1,那么最后一行确保消息行已完全从数据库中移出。现在这很好,只要它不是被删除的父消息。如果删除父消息,则将无法再访问未被选择删除的子消息。方法如下:defdelete_all_users_selected_messages(message_ids,user_id,parent_id)Message

ruby-on-rails - 有办法处理 `after_save` 和 `after_destroy` "equally"吗?

我正在使用Rails3.1.0,我想知道是否可以“平等地”处理after_save和after_destroy回调。也就是说,我需要为after_save和after_destroy回调运行相同的方法。此时我必须分别处理这些回调,即使它们完成的是同一件事:after_savedo|record|#Makeathingendafter_destroydo|record|#Makethesamethingasinthe'after_save'callbackend那么,有一种方法可以“平等地”处理after_save和after_destroy吗? 最佳答案

ruby-on-rails - Rails 中的多线程 : Circular dependency detected while autoloading constant

我有一个Rails应用程序,其中有一个Rake任务,该任务使用并发rubygem提供的多线程函数。有时我会遇到Circulardependencydetectedwhileautoloadingconstant错误。在谷歌搜索了一下后,我发现这与结合使用线程和加载Rails常量有关。我偶然发现了以下GitHub问题:https://github.com/ruby-concurrency/concurrent-ruby/issues/585和https://github.com/rails/rails/issues/26847如此处所述,您需要将从新线程调用的所有代码包装在Rails.a

ruby - gem 和 bundler : Adding a development dependency with a relative path

我正在帮助开发一系列相互关联的gem。因此,我不希望他们彼此硬依赖,但我确实希望他们在开发中运行相互使用的测试。简单吧?只需在gemspec中使用add_development_dependency,对吗?好吧,有一个小问题——git存储库包含所有的gem,所以我希望Gemfile指向gem的本地副本。这适用于硬依赖。在gemspec中,我有这一行来表示我的硬依赖:s.add_dependency"mygem-core"然后在Gemfile中,我有这一行:gem"mygem-core",:path=>"../mygem-core"这很完美。当我推出这个包时存在依赖关系,当我测试时,它将

ruby-on-rails - Rails - ActiveRecord 使用 :dependent => :destroy on condition

根据条件销毁对象的所有依赖项的最佳/DRY方法是什么。?例如:classWorker:destroyhas_many:coworkers,:dependent=>:destroyhas_many:company_credit_cards,:dependent=>:destroyend条件是销毁:ifself.is_fired?#Destroydependantsrecordselse#DonotDestroyrecordsend有没有办法在:dependent条件下使用Proc。我已经找到了单独销毁依赖项的方法,但这对于进一步的关联来说不是DRY和灵活的,注意:我编造了例子..不是实际

ruby-on-rails - 如何测试依赖: :destroy with RSpec?

我想测试我的User模型关联has_many:projects,dependent::destroy现在已经走了这么远:it"destroysdependentprojects"douser=FactoryGirl.build(:user)project=FactoryGirl.build(:project)user.projects但这给出了一个错误:Failure/Error:expect(Project.count).tochange(-1)ArgumentError:`change`requireseitheranobjectandmessage(`change(obj,:ms