Rails + MongoID +简单forms关联:#Mongoid :: Relations :: Metadata的未定义方法`options’

我有以下模型,基本上是指课程和类别。 每节课可以有一个类别,每个类别都嵌入在课程中。

class Lesson include Mongoid::Document field :title, :type => String field :category, :type => String field :price, :type => Integer field :description, :type => String field :user_id, :type => String validates_presence_of :title validates_presence_of :category validates_presence_of :price validates_presence_of :user_id validates_numericality_of :price attr_accessible :title, :category, :description, :price embeds_one :category end class Category include Mongoid::Document field :name, type: String embedded_in :lesson end 

我有一个这样的表格:

  { :class => 'well' } do |lesson_form| %>  
×
'Create', :class => 'btn btn-primary btn-large' %>

尝试渲染该表单时,我收到此错误:

 undefined method `options' for # 

有什么想法我如何在该表格中显示类别名称?

编辑

我更改了这一行:

对于这个: Category.all %>

但是当我尝试加载表单时,我得到:

 Access to the collection for Category is not allowed since it is an embedded document, please access a collection from the root document. 

不幸的是,似乎SimpleForm不支持ActiveRecord以外的ORM(例如,请参阅此问题 )。 对不起,这对你的问题不是一个很好的“回答”:/