mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Update README.md
This commit is contained in:
parent
29166b26b2
commit
7d89e26304
10
README.md
10
README.md
@ -234,7 +234,7 @@ end
|
||||
|
||||
You can specify that serializers use the lower-camel key format at the config, class or instance level.
|
||||
|
||||
````ruby
|
||||
```ruby
|
||||
|
||||
ActiveModel::Serializer.setup do |config|
|
||||
config.key_format = :lower_camel
|
||||
@ -245,17 +245,17 @@ class BlogLowerCamelSerializer < ActiveModel::Serializer
|
||||
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
|
||||
```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`.
|
||||
|
||||
@ -932,7 +932,7 @@ now generates:
|
||||
class PostSerializer < ApplicationSerializer
|
||||
attributes :id
|
||||
end
|
||||
````
|
||||
```
|
||||
|
||||
# Design and Implementation Guidelines
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user