2013-04-14 6 views
0

참고 모든 문제는이이 public_activity 보석 함께 코드이 앱은 함께 Heroku가에 충돌 : 종속> = destroy_all

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 

에게 있습니다

지역 enviromnment에서 작동 오류가

입니다

/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 그리고 로컬로 작동합니다 .. 그럼 여기서 무슨 일이 벌어지고 있습니까?

답변

1

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)을 말하는 부분은 당신을 말하고있다; 그것이 기대했던 것의 목록은 그 이전에 있습니다. 대신 :destroy을 원할 수도 있습니다. 왜 그것이 Heroku가 아닌 지역에서 효과가 있었는지 말할 수 없습니다. 일종의 보석 버전 문제 일 수 있습니다.

+0

의도 한대로 작업을 삭제합니다 (삭제 모델과 관련된 모든 알림 삭제)? –

+0

도이 다음 무엇입니까? http://apidock.com/rails/ActiveRecord/Relation/destroy_all –

+0

'파괴하라'는 의도 한대로 작동 할 것이라고 생각합니다. 여기에'has_many' 문서가 있습니다 : http://apidock.com/rails/ActiveRecord/Associations/ ClassMethods/has_many. 또한, 여러분이 제공하는 링크는 ActiveRecord'Relation'에 대한'destroy_all' 메소드를위한 것입니다. 따라서 모든 것을 파기하기 위해 코드에서 호출 할 수는 있지만 모델 정의에서 has_many 메소드의 옵션으로 제공 할 수는 없습니다. – dpassage