0
我有一个模型 -Rails的关系
class Donor < ActiveRecord::Base #recipient has name:string email:string
has_one :recipient
end
class Recipient < ActiveRecord::Base #recipient has name:string address:string
end
捐助者已经填充到数据库中。
我有以下的路线 -
match "/:donor" =>"pages#donation", :as => :donor
在这一行动,我有以下 -
@donor = Donor.find_by_name(params[:donor])
捐助者的名字已经在数据库中。
而且在我的观点 -
<%= form_for @donor do |f| %>
<div class="field">
<%= f.label :name, "Name" %> #this is prepopulated with their name - but they can change it.
<%= f.text_field :name, :class=>"input-text" %>
</div>
<div class="actions">
<%= f.submit "Submit" %>
</div>
<% end %>
我如何添加字段添加收件人的详细信息,以这种形式?
谢谢! accep_nested_attributes_for就是我正在寻找的东西。 – Finnnn