2
我搜索并尝试了很多,但我不能完成它,因为我想..所以这是我的问题。使用领域从一个协会(has_one)与formtastic在轨道模型
我的车型有:
class User < ActiveRecord::Base
has_one :profile
accepts_nested_attributes_for :profile
end
class Profile < ActiveRecord::Base
attr_accessible :user_id, :form, :title, :name, :surname, :street, :housenumber, :zipcode, :place, :phone, :mobile, :fax, :url
belongs_to :user
end
笔者认为:
<% semantic_form_for @user do |form| %>
<%= form.inputs :login, :email, :password%>
<% form.semantic_fields_for :profile do |profile| %>
<%= profile.inputs %>
<% end %>
<%= form.buttons %>
<% end %>
我的问题是,当我编辑的人话,就说明我的配置文件中的数据。我会,即使在创建用户时也显示配置文件中的字段。
非常感谢!