NameError: uninitialized constant ActiveModel::Serializers::Xml when declaring a mongomapper document model

2.9k Views Asked by At

This is the first time I use ruby mongodb ORM , and when I follow the tutorial on the website try to make a Document model :

ruby require 'mongo_mapper'

  include MongoMapper::Document

  key :title,        String
  key :content,      String
  key :published_at, Time
  timestamps!
end

my command line issue the error NameError: uninitialized constant ActiveModel::Serializers::Xml

from /Users/RobertRino/.rvm/gems/ruby-2.2.3/gems/mongo_mapper-0.14.0/lib/mongo_mapper/plugins/active_model.rb:9:in'`

and the app crashed.

I searched for solution but seems no one have encountered this problem, could anyone tell me how to solve this error ?

By the way I also try the command above in pry gem.

require 'mongo_mapper'
>>True
MongoMapper.constants
>>[:Error,
 :DocumentNotFound,
 :InvalidScheme,
 :DocumentNotValid,
 :AccessibleOrProtected,
 :InvalidKey,
 :NotSupported,
 :Document,
 ...]
 MongoMapper::Document
>> NameError ... (the same error)
1

There are 1 best solutions below

0
Jorge Fuertes On

Has been moved to external gem, please try to add this to your Gemfile:

gem 'activemodel-serializers-xml'
gem 'active_model_serializers'