creating new record instead of update

I have a simple app to track goals. I'm having an issue with a simple update.

scaffold update works great to edit the entire goal, however I have a simple update on the index page to only update 1 item on the tracker, the current value of the tracked goal.

I cannot find a solution for the problem. My simple form\_with to select the existing goal

<%= onpageupdate.select :name, options_for_select(@goals.collect { | goal | [goal.name] } )%>

and update the current goal

<%= onpageupdate.label "New Attempt" %>
<%= onpageupdate.text_field :curvalue, type: "number" %>
<%= onpageupdate.submit %>

This only creates a new record. the controller for this function reads

def onpageupdate
@goal = Goal.find(params[:id])
@goal.update(goal_params)
end

wat am i missing?

Leave a Comment