0
我有一个模型: 类资料 包括Mongoid ::文献蒙戈分贝与导轨阵列3
# PROFILE TYPE KIDS & PARENT
embeds_one :kids_type, :class_name => "ProfileKidsType"
embeds_one :parent_type, :class_name => "ProfileParentType"
end
和在ProfileKidsType模型:
class ProfileKidsType
include Mongoid::Document
field :nickname, :type => String
field :gender, :type => String
....等.. ...
embedded_in :profile, :inverse_of => :kids_type
end
in views:profiles /_form.html.ham l
= form_for @profile do |f|
.formBox
.formSection Child information
= f.label :lname, "Nick name"
= f.text_field :nickname
我怎样才能访问昵称字段在这里.....当我执行上面的代码它说的未定义的方法。
如果我想要在部分页面中,那么.. – Agnes
您可以使用相同的代码,只需像上面那样部分地将其放入:profiles /_form.html.haml,然后从另一个(非 - 部分)视图,如profiles/edit.html.haml或profiles/new.html.haml –