Instead of specifying UserV1Serializer
, you need to specify the full namespaced class name API::V1::UserV1Serializer
.
If you just specify the UserV1Serializer
, its looking for the serializer class within current controller API::V1::UsersController::UserV1Serializer
which is why you get an error as
uninitialized constant API::V1::UsersController::UserV1Serializer
.
Use this instead:
render json: user, serializer: API::V1::UserV1Serializer, root: 'user'