README.md in jb-0.6.0 vs README.md in jb-0.6.1
- old
+ new
@@ -174,16 +174,15 @@
It's also possible to render collections of partials:
```ruby
render partial: 'posts/post', collection: @posts, as: :post
-
-# or
-
-render @post.comments
```
+> NOTE: Don't use `render @post.comments` because if the collection is empty,
+`render` will return `nil` instead of an empty array.
+
You can pass any objects into partial templates with or without `:locals` option.
```ruby
render 'sub_template', locals: {user: user}
@@ -192,10 +191,10 @@
render 'sub_template', user: user
```
You can of course include Ruby `nil` as a Hash value if you want. That would become `null` in the JSON.
-To prevent Jb from including null values in the output, Active Support provides `Hash#compact!` method for you:
+You can use `Hash#compact`/`!` method to prevent including `null` values in the output:
```ruby
{foo: nil, bar: 'bar'}.compact
# => {"bar": "bar"}