It might help if you explain the error (if any) that you get. I had a similar concern regarding Active Model Serializers, and according to the documentation it appears AMS will only perform automatic serializer lookup in the app/serializers
path based on the model class, so namespaced controllers have no bearing on the serializer lookup.
There doesn't appear to be anything that prevents you from specifying any serializer class you want manually, in fact from within your namespaced controller the use of LicenseSerializer
should be looking for the namespaced class in the module Api::Product::V1
by default. Have you tried organising your serializers under a proper namespace so that rails class loading will resolve them automatically? eg, put Api::Product::V1::LicenceSerializer
in app/serializers/api/product/v1/license_serializer.rb
?
You may also want to look at roar-rails gem which integrates with rails and uses the ruby web framework agnostic ROAR gem which supports two way JSON/XML/JSON+HAL handling using a representer pattern. Be aware that you won't get jbuilder/jsonify like control over the serialization, but if you're looking at AMS I'm guessing you want to be elevated from the detail somewhat. Using ROAR you will get a uniform API based on the representer format you choose and be much closer to a true hypermedia API.
Some of the rationale for the representer/ROAR approach here, here and here.
EDIT: You may also want to consider my to_json implementation. Performance and flexibility with all the current JSON serializer libraries was a significant issue in my project. After experimenting with all the alternatives I ended up developing a clean JSON DSL and collaborating with the Oj author to develop a highly performant string-buffer/stream marshalling API. My to_json gem easily serializes 18,000 complex objects per second on budget hosting servers and has no limitations on the JSON structures that can be generated.