active_model_serializers #81

Closed
stiller opened this Issue Jul 4, 2013 · 2 comments

Comments

Projects
None yet
3 participants
@stiller

stiller commented Jul 4, 2013

When using ActiveResource with ActiveModel::Serializer, we include

ActiveModel::SerializerSupport

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

This comment has been minimized.

Show comment
Hide comment
@josh-h

josh-h 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.

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.

@rails-bot rails-bot bot added the stale label May 5, 2017

@rails-bot

This comment has been minimized.

Show comment
Hide comment
@rails-bot

rails-bot bot May 5, 2017

This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.

If it is an issue and you can still reproduce this error on the master branch,
please reply with all of the information you have about it in order to keep the issue open.

If it is a pull request and you are still interested on having it merged please make sure it can be merged clearly.

Thank you for all your contributions.

rails-bot bot commented May 5, 2017

This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.

If it is an issue and you can still reproduce this error on the master branch,
please reply with all of the information you have about it in order to keep the issue open.

If it is a pull request and you are still interested on having it merged please make sure it can be merged clearly.

Thank you for all your contributions.

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca May 5, 2017

Member

This issue has been automatically marked as stale because it has not been commented on for at least three months.

The resources of the Rails team are limited, and so we are asking for your help.

If it is an issue and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If it is a pull request and you are still interested on having it merged please make sure it can be merged clearly.

Thank you for all your contributions.

Member

rafaelfranca commented May 5, 2017

This issue has been automatically marked as stale because it has not been commented on for at least three months.

The resources of the Rails team are limited, and so we are asking for your help.

If it is an issue and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If it is a pull request and you are still interested on having it merged please make sure it can be merged clearly.

Thank you for all your contributions.

@rails-bot rails-bot bot closed this May 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment