我有一个模特 -
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 %>
如何添加字段以将收件人详细信息添加到该表单?