collectiveidea / awesome_nested_set

An awesome replacement for acts_as_nested_set and better_nested_set.
MIT License
2.39k stars 491 forks source link

Rails 6.1 destroy problem with touch: true causes FrozenError #438

Closed javinto closed 3 years ago

javinto commented 3 years ago

After upgrading to Rails 6.1 I have the following problem destroying a child record having a parent:

can't modify frozen attributes

Called from write_from_user(name, value) where name= 'parent_id'

This is caused by the following setup: acts_as_nested_set touch: true

If I leave out the touch: true option, there is no error.

It seems to be a Rails 6.1 problem, easy to reproduce. See: https://github.com/rails/rails/issues/40943

doits commented 3 years ago

FYI I have the same problem but I am not using this gem here – so maybe it is not this gem's fault.

javinto commented 3 years ago

As 'doits' found out it's seems to be a Rails 6.1 bug. You can prevent it by setting:

ActiveRecord::Base.has_many_inversing = false

if that suits your application.