gpt4 book ai didi

ruby-on-rails-3 - 应用程序在 heroku 上崩溃并显示 :dependent => :destroy_all

转载 作者:行者123 更新时间:2023-12-03 16:54:22 25 4
gpt4 key购买 nike

注意一切都在本地环境中工作

这是代码

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

这是 public_activity gem

错误是
/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它在本地工作..那么这里发生了什么?

最佳答案

source !

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

因此,在该错误消息中,显示 (:destroy_all) 的部分只是告诉你你提供了什么;它所期待的 list 是在那之前的。你可能想要 :destroy反而。不能说为什么它在本地工作而不是在 Heroku 上工作;可能是某种 gem 版本问题。

关于ruby-on-rails-3 - 应用程序在 heroku 上崩溃并显示 :dependent => :destroy_all,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16001142/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com