vt-elixir / ja_serializer

JSONAPI.org Serialization in Elixir.
Other
640 stars 148 forks source link

multiple types of attributes in same view #289

Closed utkarshvaish9 closed 5 years ago

utkarshvaish9 commented 6 years ago

I want to render attributes corresponding to the rendering call. For ex, if one attribute is defined as a list of all the elements in the table, I should be able to define another attribute with only some of the elements of the table, meaning for show page, I should have all the elements and for index page(since I don't need all of them) I should have only selected.

broodfusion commented 6 years ago

You can override the attributes as stated in the docs here: https://hexdocs.pm/ja_serializer/JaSerializer.Serializer.html#c:attributes/2 You can then define multiple attributes function and pattern match on that.