Ruby on Rails Wednesday, February 19, 2014

unknown wrote in post #1137005:
> Yes I know I can set :dependant => :delete_all
>
> but what's resoning behind this default behaviour? Is it just a legacy
> stuff?

> anyone knows why the default behaviour here is to nullify keys?

Actually, the Rails documentation explains this rather clearly, so the
behavior you're seeing is exactly as it was intended.

Excerpt:

delete_all()
Deletes all the records from the collection. For has_many associations,
the deletion is done according to the strategy specified by the
:dependent option. Returns an array with the deleted records.

If no :dependent option is given, then it will follow the default
strategy. The default strategy is :nullify. This sets the foreign keys
to NULL. For, has_many :through, the default strategy is delete_all.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/989a89a5f722d74560c4b13205361ea5%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment