products_controller.rb
def new
@product = Product.new
@product.build_discount
end
产品.rb
has_many :discounts, :dependent => :destroy
accepts_nested_attributes_for :discounts
attr_accessible :discounts_attributes
折扣.rb
belongs_to :product
_edit_product.html.erb
<%= form_for(product, :html => { :multipart => true }, :remote => true) do |f| %>
// STUFF
<%= f.fields_for :discounts do |discount_form| %>
//does not show up
<% end %>
<% end %>
块中的内容fields_for
不显示。但是,如果我更改has_many :discounts
为,则会has_many :discount
显示表单(尝试提交时出现批量分配错误)。
fields_for
关于为什么表单没有在块中呈现以及为什么在我更改复数形式时它会呈现的任何想法?