Rails - Update a single attribute : link with custom action or form with hidden fields?

后端 未结 1 1879
暗喜
暗喜 2021-01-30 07:22

Let\'s say I have a User model, with a facebook_uid field corresponding to the user\'s facebook id.

I want to allow the user to unlink his facebook account. Do do so, I

1条回答
  •  爱一瞬间的悲伤
    2021-01-30 07:45

    Not sure what your routes look like but if you have an update action it should work with the link_to. If you go with the link make sure you use a method of PUT or POST (ideally PUT because it's an update):

    link_to("Unlink your facebook account", user_path(@user, :facebook_uid => nil), :method => :put, :confirm => "Are you sure?")
    

    0 讨论(0)
提交回复
热议问题