Search code examples
ruby-on-railsruby-on-rails-3default-valuehas-manybelongs-to

What are the default values for Rails 3 for :dependent on has_many and belongs_to


In rails 3, i know that i can force deletion of dependent objects on belongs_to and has_many relations using the :dependent => :delete option. However i was wondering,

what is the default behavior if i do not specify :dependent => ...

Cheers, Hajo


Solution

  • The documentation says, "When no option is given, the behavior is to do nothing with the associated records when destroying a record." That is, deleting or destroying an object will not delete or destroy the objects that it belongs to or has many of.