1

I using grape for apis with fast_jsonapi and

What I see that I have to always provide serializer name like

CompanySerializer.new(Company.all).serializable_hash

wondering if it can auto pick serialzier name depending upon resource name or object type like it used to do with active mode serializer?

Justin Tanner
  • 14,062
  • 17
  • 82
  • 103
Muhammad Faisal Iqbal
  • 1,796
  • 2
  • 20
  • 43

1 Answers1

0

There are a couple of reasons why you'll have to explicitly mention Serializer class every time.

  1. You can have multiple Serializers for the same object/model. You may have to define multiple serializers when you need to pass different data for different requests.
  2. Usually, we have to deal with multiple API versions (like v1, v2, v3) in such case you must have multiple serializers for the same model/object for the sack of compatibility of all API versions.
Sikandar Tariq
  • 1,296
  • 1
  • 13
  • 29