Serialize all attributes when attributes invoked with no args #535

Closed
wants to merge 3 commits into
from

Projects

None yet

7 participants

@mmosche2

Implements functionality for serializing all attributes when the attributes class method is invoked with no arguments.

mmosche2 and others added some commits Mar 28, 2014
@mmosche2 mmosche2 Progress on implementing all attributes serialization support with Ac…
…tiveModel::Serializer
605f395
@AndyObtiva AndyObtiva Finished support for serializing all attributes when the attributes c…
…lass method is invoked with no arguments in an ActiveModel::Serializer
7ace022
@mmosche2 mmosche2 Merge pull request #1 from bigastronaut/master
Finished support for serializing all attributes
3b0f5a0
@unbalancedparentheses

+1. I need this since I want to serialize all attributs but one. So with this pr I can add every attribut and then using def attributes I can delete the only key I don't want.

Regards

@thoughtpunch

+1

@steveklabnik
Contributor

I understand that this is unwieldy, but the whitelist behavior is important. Thank you anyway!

@josemarluedke

@mmosche2 if you really need to get all the attributes without defining them in the serializer, you can just delegate it to object.

class UserSerializer < ActiveModel::Serializer
  delegate :attributes, to: :object
end

I have tested it on 0.8.1 and it seems to work for one object, I didn't tested when you have an ActiveRecord::Relation.

@Darkside73
Darkside73 commented Oct 24, 2016 edited

Does not work in 0.10

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