Closed michaelharro closed 10 years ago
The presenters it generates are namespaced to a version just like the controllers are.
are the serializers namespaced too?
What do you mean by "serializers"?
They are a part of ActiveModel that we are using in our project to generate json objects to be returned in our API. Here is an example https://github.com/CruGlobal/missionhub/blob/master/app/serializers/address_serializer.rb
The presenters that versionist generates are just generic classes. While they don't extend ActiveModel::Serializer out of the box, there's nothing preventing you from having them extend ActiveModel::Serializer. So they would end up looking something like this:
class V2::BasePresenter < ActiveModel::Serializer
end
class V2::FooPresenter < V2::BasePresenter
attributes :whatever
end
Untested, hand-wave, etc......
thanks, you have been extremely helpful. we really appreciate your work. ill bring this solution to the team.
Cool let me know if that doesn't work for some reason.
In our API we have needed to change the format of our responses so we have a need for a different serializer for each version of our API. Is it possible for versionist to manage serializers for each version like it does with controllers?