Can't update my nested model form for has_one association

前端 未结 3 1813
闹比i
闹比i 2020-12-08 15:09

I try to create a nested model form for the has_one association. (i\'m using Rails 4)

In my user, and adress model i have the following :

class User          


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 15:46

    There is an option to make it do a partial update if the record already exists:

    accepts_nested_attributes_for(:address, update_only: true)
    

    Documented here: http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html#method-i-accepts_nested_attributes_for

提交回复
热议问题