can't modify frozen Hash in rails3

19,172

As explained in comments, you cannot update attributes on destroyed objects.

Check with something like:

write_attribute(:value, new_value) unless destroyed?
Share:
19,172
Admin
Author by

Admin

Updated on August 02, 2022

Comments

  • Admin
    Admin almost 2 years

    I'm getting the following error,

    can't modify frozen Hash
    /home/.rvm/gems/ruby-1.9.3-p327@ui/gems/activerecord-3.2.6/lib/active_r
    ecord/attribute_methods/write.rb:38:in `[]='
    /home/.rvm/gems/ruby-1.9.3-p327@ui/gems/activerecord-3.2.6/lib/active_r
    ecord/attribute_methods/write.rb:38:in `write_attribute'
    

    from this line

    write_attribute(:value, new_value)
    

    This can be run properly for certain days. But, now it fail continously with an above error. I tried out solution for that but nothing work for me.

  • Admin
    Admin over 11 years
    Its working fine for me. But, if the condition fails the above error must return. how i overcome this?\
  • apneadiving
    apneadiving over 11 years
    I can't see any other reason why it could happen
  • D. Visser
    D. Visser about 8 years
    Of course there is a Model.destroyed? method, I should have known.