mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Merge pull request #2260 from abhaynikam/2258-fix-class-name-documentation
[docs] Fix class name documentation
This commit is contained in:
commit
f3a19bd515
@ -65,7 +65,7 @@ Where:
|
||||
- `virtual_value:`
|
||||
- `polymorphic:` defines if polymorphic relation type should be nested in serialized association.
|
||||
- `type:` the resource type as used by JSON:API, especially on a `belongs_to` relationship.
|
||||
- `class_name:` used to determine `type` when `type` not given
|
||||
- `class_name:` the (String) model name used to determine `type`, when `type` is not given. e.g. `class_name: "Comment"` would imply the type `comments`
|
||||
- `foreign_key:` used by JSON:API on a `belongs_to` relationship to avoid unnecessarily loading the association object.
|
||||
- `namespace:` used when looking up the serializer and `serializer` is not given. Falls back to the parent serializer's `:namespace` instance options, which, when present, comes from the render options. See [Rendering#namespace](rendering.md#namespace] for more details.
|
||||
- optional: `&block` is a context that returns the association's attributes.
|
||||
@ -81,6 +81,7 @@ e.g.
|
||||
```ruby
|
||||
has_one :bio
|
||||
has_one :blog, key: :site
|
||||
has_one :blog, class_name: "Blog"
|
||||
has_one :maker, virtual_value: { id: 1 }
|
||||
|
||||
has_one :blog do |serializer|
|
||||
@ -114,6 +115,7 @@ e.g.
|
||||
has_many :comments
|
||||
has_many :comments, key: :reviews
|
||||
has_many :comments, serializer: CommentPreviewSerializer
|
||||
has_many :comments, class_name: "Comment"
|
||||
has_many :reviews, virtual_value: [{ id: 1 }, { id: 2 }]
|
||||
has_many :comments, key: :last_comments do
|
||||
last(1)
|
||||
@ -127,6 +129,7 @@ e.g.
|
||||
```ruby
|
||||
belongs_to :author, serializer: AuthorPreviewSerializer
|
||||
belongs_to :author, key: :writer
|
||||
belongs_to :author, class_name: "Author"
|
||||
belongs_to :post
|
||||
belongs_to :blog
|
||||
def blog
|
||||
|
||||
Loading…
Reference in New Issue
Block a user