1
我正在尝试首次配置和使用mongoid。我已经设置了mongoid.yml配置文件简称为:Mongoid和集合
主机:本地主机
数据库:表
和我的代码:
Mongoid.load!("/mongoid.yml")
class Data
include Mongoid::Document
field :study, type: String
field :nbc_id, type: String
field :short_title, type: String
field :source, type: String
field :start_date, type: Date
end
puts Data.study
我不断收到一个错误:
NoMethodError at/undefined method `study' for Data:Class
我认为这是因为我没有指定'测试'的集合名称。不过,我无法找到如何做到这一点的例子。我是否在.yml文件或代码中指定它。什么是正确的语法。任何人都可以将我指向正确的方向吗?
Tx。
Marc。 Tx非常多! – user1311034 2012-04-21 03:45:44