ActiveRecord/ActiveModel freezes attribute values in Rails 5 (possible bug)

9 views
Skip to first unread message

Kris

unread,
Nov 10, 2017, 5:26:31 AM11/10/17
to Ruby on Rails: Talk
key = 'foo'

key.frozen? # => false

TextFieldDefinition.create(key: key)

key
.frozen? # => true (not expected)


I created a minimal example to demonstrate the bug this but it does not reproduce it.

It appears that in my production code `ActiveModel::Type::ImmutableString#cast_type`, which freezes the value, is called, but isn't in my attempt at a reproduction of the bug.

Any ideas?

I'm assuming Rails shouldn't modify input's in any way and should `#dup` them first.

Many thanks.

Kris

unread,
Nov 10, 2017, 5:34:11 AM11/10/17
to Ruby on Rails: Talk
Reply all
Reply to author
Forward
0 new messages