Merge pull request #639 from gauthier-delacroix/Unsuffixed-default-associations-keys

Allow JSONAPI unsuffixed associations keys
This commit is contained in:
Steve Klabnik
2014-10-08 14:45:46 -04:00
6 changed files with 79 additions and 2 deletions

View File

@@ -247,6 +247,18 @@ end
BlogSerializer.new(object, key_format: :lower_camel)
```
## Changing the default association key type
You can specify that serializers use unsuffixed names as association keys by default.
`````ruby
ActiveModel::Serializer.setup do |config|
config.default_key_type = :name
end
````
This will build association keys like `comments` or `author` instead of `comment_ids` or `author_id`.
## Getting the old version
If you find that your project is already relying on the old rails to_json