0

Note everything works in local enviromnment

This is the code

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

This is with the public_activity gem

the error is

/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) 

if it expects :destroy_all and I wrote :destroy_all and it works locally.. then what is going on here?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Nick Ginanto
  • 31,090
  • 47
  • 134
  • 244

1 Answers1

1

To the 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

So in that error message, the part that says (:destroy_all) is just telling you what you provided; the list of what it was expecting is before that. You probably want :destroy instead. Can't say why it worked locally and not on Heroku; might be some sort of gem version problem.

dpassage
  • 5,423
  • 3
  • 25
  • 53
  • would :destroy work as intended (delete all notifications in association with the delete model)? – Nick Ginanto Apr 14 '13 at 16:14
  • I think `:destroy` would work as intended, per the docs for `has_many` here: http://apidock.com/rails/ActiveRecord/Associations/ClassMethods/has_many. Also, the link you provide is for the `destroy_all` method on an ActiveRecord `Relation`. So you can call it in code to destroy all, but can't provide that as an option to the `has_many` method in your model definition. – dpassage Apr 14 '13 at 16:20