Skip to content

Commit 49798b5

Browse files
committed
Merge pull request rails#16300 from vast/mention-changes-to-nil-serialization-in-upgrading-from-3.2
Mention changes to `nil` handling in serialized attributes
2 parents 7bd9c87 + 4bfd0ce commit 49798b5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

guides/source/upgrading_ruby_on_rails.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ NOTE: This section is a work in progress.
5454

5555
### Serialized attributes
5656

57-
When assigning `nil` to a serialized attribute, it will be saved to the database
57+
When using a custom coder (e.g. `serialize :metadata, JSON`),
58+
assigning `nil` to a serialized attribute will save it to the database
5859
as `NULL` instead of passing the `nil` value through the coder (e.g. `"null"`
5960
when using the `JSON` coder).
6061

@@ -624,6 +625,9 @@ Rails 4.0 no longer supports loading plugins from `vendor/plugins`. You must rep
624625

625626
* Rails 4.0 has changed `serialized_attributes` and `attr_readonly` to class methods only. You shouldn't use instance methods since it's now deprecated. You should change them to use class methods, e.g. `self.serialized_attributes` to `self.class.serialized_attributes`.
626627

628+
* When using the default coder, assigning `nil` to a serialized attribute will save it
629+
to the database as `NULL` instead of passing the `nil` value through YAML (`"--- \n...\n"`).
630+
627631
* Rails 4.0 has removed `attr_accessible` and `attr_protected` feature in favor of Strong Parameters. You can use the [Protected Attributes gem](https://github.com/rails/protected_attributes) for a smooth upgrade path.
628632

629633
* If you are not using Protected Attributes, you can remove any options related to

0 commit comments

Comments
 (0)