README.md in jbuilder-2.7.0 vs README.md in jbuilder-2.8.0
- old
+ new
@@ -65,9 +65,22 @@
end
# => {"author": { "name": "David" }}
```
+
+To merge existing hash or array to current context:
+
+``` ruby
+hash = { author: { name: "David" } }
+json.post do
+ json.title "Merge HOWTO"
+ json.merge! hash
+end
+
+# => "post": { "title": "Merge HOWTO", "author": { "name": "David" } }
+```
+
Top level arrays can be handled directly. Useful for index and other collection actions.
``` ruby
# @comments = @post.comments