0

On Rails 4.

I have a Rental model which belongs_to :house and belongs_to :user

When a user destroys his/her account, the rentals associated with the user are being destroyed, although they are also still associated with a house.

What is the best way to go about keeping the rentals regardless of the user associated with the rental being destroyed? That way @house.rentals can still be viewed, but simply won't have a user object anymore.

I am not declaring dependent: :destroy, so I thought this would be default behavior, but it is not.

thx!

Kathan
  • 1,428
  • 2
  • 15
  • 31

1 Answers1

0

I looked at the answer here and could you change destroying the account to instead de-activating it? Or, can you do a @user.delete instead of @user.destroy to avoid destroying the child records (assuming you don't have foreign keys)?

Community
  • 1
  • 1
greatwhitenorth
  • 97
  • 1
  • 10