Skip to content

Calling field.attributes freezes the Hash #8

@dysbulic

Description

@dysbulic

Why does accessing .attributes freeze the storage?

2.3.3 :013 > u = User.last
2.3.3 :014 > u.header_notify = { comment: false }
 => {:comment=>false}
2.3.3 :015 > u.header_notify.attributes
 => {:add_project=>true, :comment=>true, :reply=>false, :like=>true, :follow=>true, :mention=>true}
2.3.3 :016 > u.header_notify = { comment: false }
RuntimeError: can't modify frozen Hash

I suppose it is to prevent modification, but wouldn't .dup be better?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions