Can't update my nested model form for has_one association

前端 未结 3 1812
闹比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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 15:32

    in your controller UsersController, in the update method, add the address: :id to the address permitted attributes. Like this:

    params.require(:user).permit(:user_name, address_attributes: [:id, :street]))
    

提交回复
热议问题