Skip to content

Commit 6567989

Browse files
Tonkpilsbf4
authored andcommitted
Specify how to get the instance of the serializer (#1861)
[DOC] `SerializableResource#serializer` vs. `SerializableResource#serializer_instance` [ci skip]
1 parent 4ff33a7 commit 6567989

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

docs/howto/outside_controller_use.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ model_json = serializable_resource.as_json
2222

2323
### Looking up the Serializer for a Resource
2424

25-
If you want to retrieve a serializer for a specific resource, you can do the following:
25+
If you want to retrieve the serializer class for a specific resource, you can do the following:
2626

2727
```ruby
2828
# Create our resource
@@ -41,7 +41,13 @@ You could also retrieve the serializer via:
4141
ActiveModelSerializers::SerializableResource.new(post, options).serializer
4242
```
4343

44-
Both approaches will return an instance, if any, of the resource's serializer.
44+
Both approaches will return the serializer class that will be used for the resource.
45+
46+
Additionally, you could retrieve the serializer instance for the resource via:
47+
48+
```ruby
49+
ActiveModelSerializers::SerializableResource.new(post, options).serializer_instance
50+
```
4551

4652
## Serializing before controller render
4753

0 commit comments

Comments
 (0)