You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -313,6 +314,20 @@ You can pass a `meta` argument to specify top-level metadata:
313
314
JSONAPI::Serializer.serialize(post, meta: {copyright:'Copyright 2015 Example Corp.'})
314
315
```
315
316
317
+
### Explicit serializer discovery
318
+
319
+
By default, jsonapi-serializers assumes that the serializer class for `Namespace::User` is `Namespace::UserSerializer`. You can override this behavior on a per-object basis by implementing the `jsonapi_serializer_class_name` method.
320
+
321
+
```ruby
322
+
classUser
323
+
defjsonapi_serializer_class_name
324
+
'SomeOtherNamespace::CustomUserSerializer'
325
+
end
326
+
end
327
+
```
328
+
329
+
Now, when a `User` object is serialized, it will use the `SomeOtherNamespace::CustomUserSerializer`.
330
+
316
331
## Relationships
317
332
318
333
You can easily specify relationships with the `has_one` and `has_many` directives.
0 commit comments