docs/associations.md in panko_serializer-0.6.0 vs docs/associations.md in panko_serializer-0.7.0
- old
+ new
@@ -3,24 +3,38 @@
A serializer can define it's own associations - both `has_many` and `has_one` to serializer under the context of the object.
For example:
```ruby
-class PostSerializer < Panko::Serailizer
+class PostSerializer < Panko::Serializer
attributes :title, :body
has_one :author, serializer: AuthorSerializer
has_many :comments, each_serializer: CommentSerializer
end
```
+# Associations with aliases
+
+An association key name can be aliased with the `name` option.
+
+For example:
+the `actual_author` property will be converted to `alias_author`.
+```ruby
+class PostSerializer < Panko::Serializer
+ attributes :title, :body
+
+ has_one :actual_author, serializer: AuthorSerializer, name: :alias_author
+ has_many :comments, each_serializer: CommentSerializer
+end
+```
### Inference
Panko can find the type of the serializer by looking at the realtionship name, so instead specifying
the serializer at the above example, we can -
```ruby
-class PostSerializer < Panko::Serailizer
+class PostSerializer < Panko::Serializer
attributes :title, :body
has_one :author
has_many :comments
end