I have a Rails form that allows users to update the values of a payment record they previously created.
Everything is working as anticipated, except that the select fields are not saving the appropriate value when the form is submitted. I think this is because the helper that creates those fields isn’t referencing the payment object, but I can’t figure out the format I would use to do that.
Here’s sample code:
<%= form_for @payment do |f| %>
# Works
<%= f.label :amount %>
$ <%= f.text_field :amount, :size => 7 %>
# Doesn't work
<%= f.label :responsibility %>
<%= select :payment, :responsibility, @resp_options, {:include_blank => true} %>
<%= f.submit "Edit this payment" %>
<% end %>
your select statement should looks like this:
f.select :responsibility, @resp_options, {:include_blank => true}