collectiveidea/awesome_nested_set

Rails 6.1 destroy problem with touch: true causes FrozenError

Closed this issue · 2 comments

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: rails/rails#40943

doits commented

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

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.