aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model
diff options
context:
space:
mode:
authorNick Veys <nick@codelever.com>2014-11-20 14:50:24 -0600
committerNick Veys <nick@codelever.com>2014-11-20 14:50:24 -0600
commitf78006d6563ce4128a04be2fea5122f367957833 (patch)
tree99bbf4ac239fcead3f4d35ebd7d007ac567dd016 /activemodel/lib/active_model
parentb0f44c9ff0be84ebc42760029adeeb9dd954655f (diff)
downloadrails-f78006d6563ce4128a04be2fea5122f367957833.tar.gz
rails-f78006d6563ce4128a04be2fea5122f367957833.tar.bz2
rails-f78006d6563ce4128a04be2fea5122f367957833.zip
Fixing documentation in JSON#from_json
Commit d67b289 introduced a tiny regression in the docs for #from_json, true needs to be included when the root node is present.
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r--activemodel/lib/active_model/serializers/json.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/activemodel/lib/active_model/serializers/json.rb b/activemodel/lib/active_model/serializers/json.rb
index 77f2a64b11..b66dbf1afe 100644
--- a/activemodel/lib/active_model/serializers/json.rb
+++ b/activemodel/lib/active_model/serializers/json.rb
@@ -130,10 +130,10 @@ module ActiveModel
#
# json = { person: { name: 'bob', age: 22, awesome:true } }.to_json
# person = Person.new
- # person.from_json(json) # => #<Person:0x007fec5e7a0088 @age=22, @awesome=true, @name="bob">
- # person.name # => "bob"
- # person.age # => 22
- # person.awesome # => true
+ # person.from_json(json, true) # => #<Person:0x007fec5e7a0088 @age=22, @awesome=true, @name="bob">
+ # person.name # => "bob"
+ # person.age # => 22
+ # person.awesome # => true
def from_json(json, include_root=include_root_in_json)
hash = ActiveSupport::JSON.decode(json)
hash = hash.values.first if include_root