MongoMapper and ActiveModel Serializers

92 views
Skip to first unread message

Benigno Hernández

unread,
Jan 14, 2015, 6:34:47 PM1/14/15
to mongo...@googlegroups.com
Hi,

I'm building a JSON API with Rails and it's my first time using MongoDB. I've created JSON APIs before using the gem "ActiveModel Serializers" (active_model_serializers). I'm getting the following error when trying to serialize a mongo record to JSON:

"undefined method `read_attribute_for_serialization' for #<MongoMapper::Plugins::Querying::DecoratedPluckyQuery"

Even when I included the following modules in my models:  "include ActiveModel::Serialization; include ActiveModel::SerializerSupport", I can't get rid off the error. I use ActiveModel Serializers because it's very simple to format the JSON responses from Rails.

Does anyone else has experienced this error? Am I doing it wrong trying to "serialize to JSON" a mongo document (that it's stored in JSON)?

Thank you in advance.
Reply all
Reply to author
Forward
0 new messages