josevalim/active_model_serializers — Issue #13: Cannot use STI w/has_many
Author: Adman65
Created: 2011-12-12 15:41:44+00:00
State: open

How do you think we should do this?

I have this class structure, Message, Im < Message, Sms < Message, and Email < Message. How would I serialize all the messages?

I could loop over them myself, but we should make the library robust enough to support this use case.

For implementation, I guess it would be like the polymorphic has_one, but going up the class tree until we can find a serializer. Question is, where would it stop? It wouldn't make sense to go _all_ the way up tree. Perhaps define a method on each ActiveModel instance to determine what to use to serialize it.

What do you think? I think this the last problem I'll run into for bit with this library :)