Skip to content

active_model_serializers #81

stiller opened this Issue Jul 4, 2013 · 1 comment

2 participants

stiller commented Jul 4, 2013

When using ActiveResource with ActiveModel::Serializer, we include


which provides

 alias :read_attribute_for_serialization :send

However, this does not seem to work for ActiveResource, as the original method is still called. A possible workaround:

  1. Require ActiveResource before ActiveModel::Serializer in Gemfile
  2. Manually add the alias to the AR models.
josh-h commented Dec 19, 2013

I ran into this as well. I created a module that forwards read_attribute_for_serialization calls from the ActiveModel serializer to the ActiveResource object. I found that I had to make the following call to make the Active Model ArraySerializer load custom AR serializers:

ActiveResource::Collection.send(:include, ActiveModel::ArraySerializerSupport)

If AR implemented read_attribute_for_serialization it would solve half of the issue. Though, I'm not sure what the semantic for the method are, and any consequences for adding the method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.