Rails has_one remove link

The only way to destroy the has_one and belongs_to association by setting FK to nil on the assign_to object?

+3
source share
2 answers

Since I remember, as soon as you set the drop in the cascade, you just need to delete the object and remove all the dependencies.

Hope this helps, Greetings

+1
source

Does it work @obj1.obj2 = nil?

But this does not delete the belongs_to entry. If you want to do this, you need to do@obj1.obj2.delete

+1
source

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


All Articles