Closed casperbrike closed 8 years ago
This needs tests, CHANGELOG entry, a better commit message, etc., please. The build has to pass too.
FWIW, I believe this will be fixed by this pull if you are running into this with ASM v0.10.0+
v0.10.x ASM ActiveModel::Serializer.serializer_for
no longer handles a passed in namespace key, so we have to handle namespacing within grape-active_model_serializers.
@casperbrike can you check your project against master?
@casperbrike - this should be fixed on master. please test this against master and create another pull request or issue if this isn't resolved
@drn I tested against master and got the same error, but against namespace-inferred-serializer
everything works fine. I think, this is no need create another pull request
Thanks @casperbrike - the collection handling in the namespace-inferred-serializer
branch will be merged with https://github.com/ruby-grape/grape-active_model_serializers/pull/61 sometime today. I forgot to include it with my previous push to master. Appreciate you following up!
@casperbrike - https://github.com/ruby-grape/grape-active_model_serializers/pull/61 has been merged - let me know if you have any issues with it
ActiveModel::Serializer.serializer_for(resource, ams_options))
called even ifoptions[:serializer]
exists. This causes some strange behavior. Here is example. Lets assume we have modelUser
and serializerUserSerializer
in module V1 (model is in no module, serializer is inserializers/v1/user_serializer.rb
file). And we have simple api for user:In that case, Grape-AMS will trying to load
UserSerializer
(on the assumption of model name). AMS can find fileuser_serializer.rb
, but he can't get constUserSerializer
in this file, because in this file we haveV1::UserSerializer
const, so we get error'Unable to autoload constant UserSerializer, expected /.../serializers/v1/user_serializer.rb to define it'
. But we already specified that we wantV1::UserSerializer
. If we specify some other serializer,V1::OtherSerializer
or justWithoutModuleSerializer
, we will get this error again.