Rails 3.1: accepts_nested_attributes_for and has_one association - won't work?

后端 未结 2 1627
别那么骄傲
别那么骄傲 2021-01-12 04:09

I\'m trying to use accepts_nested_attributes_for on a has_one association model, and getting absolutely nowhere :-(

I have two models, a user and a location. A user

2条回答
  •  天命终不由人
    2021-01-12 04:16

    Try this instead

    <%= f.fields_for :location do |location_fields| %>
    

    Rather than giving it the object itself, tell rails what association you want to have it load for

提交回复
热议问题