私が持っているBill多くの持っているオブジェクト、Dueオブジェクトを。Dueオブジェクトはまたに属しますPerson。Billとその子をDuesすべて1ページで作成できるフォームが必要です。このRailscastの属性と同様に、ネストされた属性を使用してフォームを作成しようとしています。
関連するコードを以下に示します。
due.rb
class Due < ActiveRecord::Base
    belongs_to :person
    belongs_to :bill
endbill.rb
class Bill < ActiveRecord::Base
    has_many :dues, :dependent => :destroy 
    accepts_nested_attributes_for :dues, :allow_destroy => true
endbills_controller.rb
  # GET /bills/new
  def new
      @bill = Bill.new
      3.times { @bill.dues.build }
  endbills / _form.html.erb
  <%= form_for(@bill) do |f| %>
    <div class="field">
        <%= f.label :company %><br />
        <%= f.text_field :company %>
    </div>
    <div class="field">
        <%= f.label :month %><br />
        <%= f.text_field :month %>
    </div>
    <div class="field">
        <%= f.label :year %><br />
        <%= f.number_field :year %>
    </div>
    <div class="actions">
        <%= f.submit %>
    </div>
    <%= f.fields_for :dues do |builder| %>
        <%= render 'due_fields', :f => builder %>
    <% end %>
  <% end %>bills / _due_fields.html.erb
<div>
    <%= f.label :amount, "Amount" %>        
    <%= f.text_field :amount %>
    <br>
    <%= f.label :person_id, "Renter" %>
    <%= f.text_field :person_id %>
</div>bills_controller.rbへのUPDATE これは機能します!
def bill_params 
  params
  .require(:bill)
  .permit(:company, :month, :year, dues_attributes: [:amount, :person_id]) 
end適切なフィールドがページに表示され(Personまだドロップダウンはありません)、送信は成功します。ただし、子会費はデータベースに保存されず、サーバーログにエラーがスローされます。
Unpermitted parameters: dues_attributesエラーの直前に、ログはこれを表示します:
Started POST "/bills" for 127.0.0.1 at 2013-04-10 00:16:37 -0700
Processing by BillsController#create as HTML<br>
Parameters: {"utf8"=>"✓", 
"authenticity_token"=>"ipxBOLOjx68fwvfmsMG3FecV/q/hPqUHsluBCPN2BeU=",
 "bill"=>{"company"=>"Comcast", "month"=>"April ", 
"year"=>"2013", "dues_attributes"=>{
"0"=>{"amount"=>"30", "person_id"=>"1"}, 
"1"=>{"amount"=>"30", "person_id"=>"2"},
 "2"=>{"amount"=>"30", "person_id"=>"3"}}}, "commit"=>"Create Bill"}Rails 4に変更はありますか?