serializable_hash and as_json should take options = nil

per ActiveModel::Serialization#serializable_hash
96bb004fc6/activemodel/lib/active_model/serialization.rb
    def serializable_hash(options = nil)
          options ||= {}

Otherwise, passing in nil to `as_json` or `serializable_hash`
makes things blow up when passing nil into attributes
This commit is contained in:
Benjamin Fleischer
2015-06-16 12:53:34 -05:00
parent f67fd976ec
commit 2d24dded14
4 changed files with 10 additions and 8 deletions

View File

@@ -4,9 +4,10 @@ module ActiveModel
class Serializer
class Adapter
class Json < Adapter
def serializable_hash(options = {})
def serializable_hash(options = nil)
options ||= {}
if serializer.respond_to?(:each)
@result = serializer.map{|s| FlattenJson.new(s).serializable_hash }
@result = serializer.map{|s| FlattenJson.new(s).serializable_hash(options) }
else
@hash = {}