为什么mongoid在我的模型上抛出未定义的方法`field'?

时间:2012-01-25 19:55:37

标签: ruby-on-rails-3 mongoid

我有以下内容:

class Email
  include ::Mongoid::Timestamps
  include ::Mongoid::Document

  field :email_address, :type => String
  field :user_id, :type => Integer
  field :campaign, :type => String
  field :stream, :type => String
  field :component, :type => String
  embeds_many :actions
end

并且rails抱怨它无法找到字段方法定义。 有人知道为什么吗?

1 个答案:

答案 0 :(得分:5)

您必须在Mongoid::Timestamps之后加入Mongoid::Document