Rails dependent which options are possible?

断了今生、忘了曾经 提交于 2019-12-08 16:22:22

问题


I get the following error in Rails 4

dependent option must be one of destroy delete

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

thank you for your help


回答1:


Docs are available here

Looks like the following options are supported:

  • :destroy - causes all the associated objects to also be destroyed.
  • :delete_all - causes all the associated objects to be deleted directly from the database (so callbacks will not be executed).
  • :nullify - causes the foreign keys to be set to NULL. Callbacks are not executed.
  • :restrict_with_exception - causes an exception to be raised if there are any associated records.
  • :restrict_with_error - causes an error to be added to the owner if there are any associated objects.


来源:https://stackoverflow.com/questions/25962326/rails-dependent-which-options-are-possible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!