Rails - I need a checkbox to change a field in the DB

后端 未结 3 1840
我在风中等你
我在风中等你 2021-02-10 09:35

I know I have done this before, but for the life of me I can\'t figure it out.

I have a table with a \"called\" field in it. I need to use a checkbox to update the db an

3条回答
  •  死守一世寂寞
    2021-02-10 10:04

    In view:

    <% form_for :rsvp, :url => {:controller => "rsvp", :action => "update"} do |f| %>
       <%= f.check_box :called %>
       <%= f.submit "Update" %>
    <% end %>
    

    In rsvp controller, update method:

    @RSVPobject.updateAttribute(:called, params[:rsvp][:called])
    

提交回复
热议问题