MongoDB NameError: uninitialized constant

itsvoid · 2012年09月05日 · 最后由 cantin 回复于 2012年09月06日 · 8556 次阅读

有一个 mongo mapper model,定义如下:

class CustomSearchEngine include MongoMapper::EmbeddedDocument key :author_uid, ObjectId, required: true key :category, Integer, required: true key :access, Integer, default: 0, required: true key :voters, Array key :votes, Integer, default: 0 key :current_links, Integer, default: 1 key :history_links, Integer, default: 1

# custom search engine specification one :specification # custom search engine annotations many :annotations

many :comments timestamps!

belongs_to :user

attr_accessible :category, :access, :voters, :votes

end

我在 console 下面,运行 CustomSearchEngine.new,报错:

NameError: uninitialized constant Specifications

这是什么问题?

你的程序哪里调用到 Specifications 这个类了,找找看是不是写错了

#1 楼 @cantin specification 不会是关键词吧?

不是,应该是哪里写错了,全局搜索 specifications 这个词看看

需要 登录 后方可回复, 如果你还没有账号请 注册新账号