Ruby on rails 3 应用程序在heroku上崩溃:依赖=>;:毁灭一切
注意:在当地环境中,一切都能正常工作 这是密码Ruby on rails 3 应用程序在heroku上崩溃:依赖=>;:毁灭一切,ruby-on-rails-3,heroku,crash,dependent-destroy,Ruby On Rails 3,Heroku,Crash,Dependent Destroy,注意:在当地环境中,一切都能正常工作 这是密码 PublicActivity::ORM::ActiveRecord::Activity.class_eval do attr_accessible :reference_type, :reference_id has_many :notifications, :dependent => :destroy_all has_many :users, :through => :notifications end 这是与公共_活动有
PublicActivity::ORM::ActiveRecord::Activity.class_eval do
attr_accessible :reference_type, :reference_id
has_many :notifications, :dependent => :destroy_all
has_many :users, :through => :notifications
end
这是与公共_活动有关的
错误是
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/associations/builder/has_many.rb:20:in `configure_dependency': The :dependent option expects either :destroy, :delete_all, :nullify or :restrict (:destroy_all) (ArgumentError)
如果它需要:destroy_all
并且我编写了:destroy_all
并且它在本地工作。。那这里发生了什么事?到那边去
所以在这个错误消息中,说
(:destroy_all)
的部分只是告诉你你提供了什么;它所期待的是在那之前。您可能想要:销毁。说不出为什么它在本地有效而在Heroku上无效;可能是某种gem版本的问题 是否会:按预期销毁工作(删除与删除模型相关的所有通知)?我认为:销毁将按预期工作,因为的文档中有许多。另外,您提供的链接是针对ActiveRecord关系上的destroy\u all
方法的。因此,您可以在代码中调用它来销毁所有内容,但不能将其作为模型定义中的has\u many
方法的选项提供。
unless options[:dependent].in?([:destroy, :delete_all, :nullify, :restrict])
raise ArgumentError, "The :dependent option expects either :destroy, :delete_all, " \
":nullify or :restrict (#{options[:dependent].inspect})"
end