Matt Jones wrote in post #1152815:
> On Friday, 18 July 2014 02:24:59 UTC-4, Ruby-Forum.com User wrote:
> saved_children = pfrom.children.to_a
> pfrom.children = []
> pto.children = pto.children + saved_children.
I finally found the time to rewrite this part of my application
according to this suggestion, but I now get an error "can't modify
frozen Hash", when I try to add the saved children. The actual code
which I am using is here:
# tempdict is "pfrom" and targetdict is "pto"
targetdict=Dict.find_by_id(....)
# creating and saving a tempdict together with several children,
i.e. cards
tempdict=Dict.new(....)
tempdict.save!
# Code for creating and adding the children omitted for brevity
....
cards_to_add=tempdict.cards.to_a
tempdict.cards=[]
targetdict.cards += cards_to_add
I find it strange that I get the error on the last line. The error
message is usually an indication that I am trying to save something
which has been deleted already, but in this case, no deletion had been
done on 'targetdict' before.
Any idea, where this error could come from?