Does Rails depend on which options are possible?

I get the following error in Rails 4

dependent parameter must be one of delete delete

apparently https://github.com/rails/rails/issues/3458 other options were previously supported. But what is possible now? I did not find any other documentation

thank you for your help

+6
source share
2 answers

Documents are available here.

It looks like the following options are supported:

  • :destroy - destroys all related objects.
  • :delete_all - deletes all related objects directly from the database (therefore, callbacks will not be performed).
  • :nullify - foreign keys are set to NULL. Callbacks are not made.
  • :restrict_with_exception - throws an exception if there are related records.
  • :restrict_with_error - Adds an error to the owner if there are related objects.
+9
source

Not sure if this is what you had in mind, but you can write in your model, for example.

 has_many :items, dependent: :destroy 
-2
source

Source: https://habr.com/ru/post/975608/


All Articles