0

我有一个名为Person拥有的模型Venue。课程如下:

应用程序/模型/person.rb

class Person < ActiveRecord::Base
     attr_acessible :height
     has_one :venue
end

应用程序/模型/venue.rb

class Venue < ActiveRecord::Base
     attr_acessible :location
end

现在,如果我想制作一个表格,如果Person没有,它会是这样的has_one Venue

<%= form_for :person do |f| %>
    <%= f.text_field :height %>
<% end %>

如果我想用这个表单Venue为此创建对象,我该怎么做?Person

4

1 回答 1

0

弄清楚了。在这种情况下,您将使用fields_for模拟子模型的字段呈现。

于 2012-07-27T22:11:43.153 回答