Begginer question: how to edit using options_from_collection


I have been stuck on this problem for 2 hours and still have no idea how
to do it. Basically I have a relationship between Workout and Exercise

Exercise has many Work out

anyway in my code at Workout.view the edit.html that was generated
through scaffold I wrote this

<% form_for(@workout) do |f| %>
  <b>Exercise</b><br />
  <%= select_tag "exercise",
  options_from_collection_for_select(Exercise.find_all, "id", "name",
@workout.exercise_id) %>
    <%= f.submit "Update" %>
<% end %>

For some reason it does not update when I click it. I don't have any
errors but it just doesn't update. Does anyone know why?

Any help would be apperciated. Thanks



What doesn't update when you click on what?

If I had to guess, I'd say that your workout record isn't updating
when you click on the update button because you're using "select_tag"
instead of "", so your exercise information shows up in
params[:exercise] instead of params[:workout][:exercise]. You're
probably saving your workout record based on params[:workout], so it's
not getting the exercise info.