rails/rails — pull request #16059 by jenncoop (2014-07-05 00:38:12+00:00)
Title: Fixed issue with ActiveRecord serialize object as JSON

With 4.1.x `serialize` started returning a string when `JSON` was passed as the second attribute. It will now return a hash as per previous versions (prior to 4.1.x)

Example: An ActiveRecord model named `Post` with a `comment` column that uses the serialize method to convert a `Comment` object to `JSON`.

```ruby
class Post < ActiveRecord::Base
serialize :comment, JSON
end

class Comment
include ActiveModel::Model
attr_accessor :category, :text
end

post = Post.create!
post.comment = Comment.new(category: "Animals", text: "This is a comment about squirrels.")
post.save!

# This will now return a hash
post.comment
```

When `JSON` is used with `serialize`, ActiveRecord will use the new `ActiveRecord::Coders::JSON` coder which delegates `ActiveRecord::Coders::JSON.dump/load` to `ActiveSupport::JSON.encode/decode`.

Fixes #15594