active_model_serializers: undefined method `embed'
I’m using the 0.10.0.rc1 version because 0.9.x doesn’t work, but with this definition of the serializer:
class Api::V1::ItinerarySerializer < ActiveModel::Serializer
attributes :id, :title
embed :ids, include: true
has_many :pois, serializer: Api::V1::PoiSerializer
end
I get this error:
NoMethodError (undefined method `embed' for Api::V1::ItinerarySerializer:Class):
app/serializers/api/v1/itinerary_serializer.rb:4:in `<class:ItinerarySerializer>'
app/serializers/api/v1/itinerary_serializer.rb:1:in `<top (required)>'
app/controllers/api/v1/itineraries_controller.rb:29:in `update'
Embed is deprecated? How can I generate the “old” JSON including associated objects, like this:
{
"itinerary": {
"poi_ids": [1,4,5]
},
{ "pois": [
// POI serialized objects
]}
}
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 24 (13 by maintainers)
Commits related to this issue
- temporarily remove embed. see https://github.com/rails-api/active_model_serializers/issues/938 — committed to metamaps/metamaps by devvmh 8 years ago
- Remove deprecated method `embed` https://github.com/rails-api/active_model_serializers/issues/938 — committed to singularities/circular-work by atd 8 years ago
Here’s my workaround for now, similar to @joaomdmoura above:
some work on this is actually being done here: https://github.com/rails-api/active_model_serializers/pull/1845
+1. This is a necessity for
active-model-adapter
. Would really like it back.@alexloginov in the latest version of AMS,
include
be used from the render call 😃