ActiveModel Serialization is not supported for embedded documents...if you want a workaround check this out http://discuss.emberjs.com/t/extend-ds-activemodelserializer-support-for-embedded-objects-belongsto-relationship-using-has-one/3392
Rails serializer isn't called on Mongoid embedded class
-
16-06-2023 - |
Question
I have two mongoid models, let's call them Model
and ModelChild
. This is relation in Model
:
embeds_many :readings, class_name: 'ModelChild', inverse_of: :model
And this is relation in model_child
:
embedded_in :model, class_name: 'Model', inverse_of: :readings
The problem is that ModelSerializer
is called, but ModelChildSerializer
isn't. Am I doing something wrong or is this by design? If it's by design, how can I make it call ModelChildSerializer
.
EDIT:
Controller's rendering call:
render json: obj, serializer: ObjSerializer
And code in ObjSerializer
:
def attributes
data = super
data[:data] = ActiveModel::ArraySerializer.new(data[:data])
data
end
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow