到目前为止,我有两个模型,用户和个人资料
Class User < ActiveRecord::Base
has_one :profile
accepts_nested_attributes_for :profile
Class Profile < ActiveRecord::Base
belongs_to :user
在我的有效管理模式
上form do |f|
f.inputs "User" do
f.input :email
#code to get the profile data
end
f.action :submit
end
所以我想在用户表单上获取配置文件数据我尝试了几件事,但我无法得到它们。
答案 0 :(得分:0)
像
这样的东西f.inputs 'Profile', :for => [:profile, f.object.profile || Profile.new] do |profile_form|
profile_form.input ...
...
end
f.inputs“User”块内的应该可以正常工作。只需使用profile_form在此块中设置Profile的属性。