simple_fields_for not showing up [rails 4]

孤街醉人 提交于 2019-12-03 11:04:27

I figured this out, ... the problem was

fields_for will loop over a collection association, rendering out as many times as there are items in it, which means 0 times if the association is empty

so to fix the problem I had to add

@product = Product.new
@product.product_options.build

to the index action in the controller.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!