Description
After updating to v0.10.0.rc4
tag I had to specify ActiveModelSerializers.config.adapter = :json
in an initializer for a rails application in order to make active_model_serializer to add root key to the the response. However if the model is nested the key is built using the whole class name. For example if I specify a model:
class Users::Profile < ActiveRecord::Base
end
and then in controller:
class Users::ProfilesController < ApplicationController
def show
@profile = Users::Profile.first
respond_with @profile, serializer: UserProfileSerializer
end
end
It will build json containing the root key as follows: {'users/profile': {'name': 'test'}}
. Is there any way to make active_model_serializer to use the class itself ignoring nesting? I've looked through the source code and found a method json_key
which builds the root element of the json. But overriding that method is not always working. Moving root element build method to a overridable strategy may be a good feature request candidate