Mongoid gives uninitialized constant Mongo

为君一笑 提交于 2020-01-15 03:31:31

问题


I'm trying to use mongoid but it outputs this error:

uninitialized constant 'Mongo'

Here is my code:

require "mongoid"

Mongoid.configure do |config|
    config.master = Mongo::Connection.new("localhost",27017).db("arthist")
end

class Artist
    include Mongoid::Document
    field :name, type: String
end 

a = Artist.create(name: "hoge")

Do you have any idea?


回答1:


include gem mongo in your Gemfile and restart the server it should do the trick.



来源:https://stackoverflow.com/questions/12188219/mongoid-gives-uninitialized-constant-mongo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!