Mongoid gives uninitialized constant Mongo

2019-07-15 11:17发布

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条回答
你好瞎i
2楼-- · 2019-07-15 12:12

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

查看更多
登录 后发表回答