Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Correcting some malformed JSON in the documentation

  • Loading branch information...
commit 06b5c235c52ea06e4f813b8d42838db2f361b533 1 parent 6564a5b
Adam Lassek alassek authored
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/jbuilder.rb
8 lib/jbuilder.rb
View
@@ -52,7 +52,7 @@ def child!
# json.age calculate_age(person.birthday)
# end
#
- # [ { "David", 32 }, { "Jamie", 31 } ]
+ # [ { "name": David", "age": 32 }, { "name": Jamie", "age": 31 } ]
#
# If you are using Ruby 1.9+, you can use the call syntax instead of an explicit extract! call:
#
@@ -65,7 +65,7 @@ def child!
# json.age calculate_age(person.birthday)
# end
#
- # { "people": [ { "David", 32 }, { "Jamie", 31 } ] }
+ # { "people": [ { "name": David", "age": 32 }, { "name": Jamie", "age": 31 } ] }
def array!(collection)
collection.each do |element|
child! do |child|
@@ -80,7 +80,7 @@ def array!(collection)
#
# json.extract! @person, :name, :age
#
- # { "David", 32 }, { "Jamie", 31 }
+ # { "name": David", "age": 32 }, { "name": Jamie", "age": 31 }
#
# If you are using Ruby 1.9+, you can use the call syntax instead of an explicit extract! call:
#
@@ -117,7 +117,7 @@ def target!
def method_missing(method, *args)
case
# json.comments @post.comments { |json, comment| ... }
- # { "comments": [ { ...}, { ... } ] }
+ # { "comments": [ { ... }, { ... } ] }
when args.one? && block_given?
_yield_iteration(method, args.first) { |child, element| yield child, element }
Please sign in to comment.
Something went wrong with that request. Please try again.