more README markdown cleanup

This commit is contained in:
Tee Parham 2012-07-23 12:55:47 -06:00
parent f8263153b6
commit 3ecf22a249

View File

@ -91,8 +91,8 @@ render :json => @post, :serializer => FancyPostSerializer
## Arrays ## Arrays
In your controllers, when you use `render :json` for an array of objects, AMS will In your controllers, when you use `render :json` for an array of objects, AMS will
use ActiveModel::ArraySerializer (included in this project) as the base serializer, use `ActiveModel::ArraySerializer` (included in this project) as the base serializer,
and the individual Serializer for the objects contained in that array. and the individual `Serializer` for the objects contained in that array.
```ruby ```ruby
class PostSerializer < ActiveModel::Serializer class PostSerializer < ActiveModel::Serializer
@ -112,14 +112,14 @@ Given the example above, the index action will return
```json ```json
{ {
"posts": "posts":
[ [
{ "title": "Post 1", "body": "Hello!" }, { "title": "Post 1", "body": "Hello!" },
{ "title": "Post 2", "body": "Goodbye!" } { "title": "Post 2", "body": "Goodbye!" }
] ]
} }
``` ```
By default, the root element is the name of the controller. For example, PostsController By default, the root element is the name of the controller. For example, `PostsController`
generates a root element "posts". To change it: generates a root element "posts". To change it:
```ruby ```ruby
@ -129,7 +129,7 @@ render :json => @posts, :root => "some_posts"
You may disable the root element for arrays at the top level, which will result in You may disable the root element for arrays at the top level, which will result in
more concise json. To disable the root element for arrays, you have 3 options: more concise json. To disable the root element for arrays, you have 3 options:
#### 1. Disable root globally for in ArraySerializer. In an initializer: #### 1. Disable root globally for in `ArraySerializer`. In an initializer:
```ruby ```ruby
ActiveModel::ArraySerializer.root = false ActiveModel::ArraySerializer.root = false
@ -141,7 +141,7 @@ ActiveModel::ArraySerializer.root = false
render :json => @posts, :root => false render :json => @posts, :root => false
``` ```
#### 3. Create a custom ArraySerializer and render arrays with it: #### 3. Create a custom `ArraySerializer` and render arrays with it:
```ruby ```ruby
class CustomArraySerializer < ActiveModel::ArraySerializer class CustomArraySerializer < ActiveModel::ArraySerializer