My app has Users who bet on matches. A single bet is called a "tipp".
I have the following (working) form where Users can EDIT their bets:
<%= form_for @user, :url => { :action => "update_tipps" } do |user_form| %>
<%= user_form.fields_for :tipps do |tipp_form, index| %>
<%= tipp_form.text_field :tipp1 %><br/>
<%= tipp_form.text_field :tipp2 %><br/>
<% end %>
<%= submit_or_cancel(user_form) %>
<% end %>
With this form a User can edit all of his bets / tipps at once.
My question:
How can i specify the tipps which a user can edit? I dont want a user to get a list of all his bets, but just a subset of his bets.
For example like this:
<%= user_form.fields_for :tipps.where("match_id = ?", 5) do |tipp_form, index| %>
<%= tipp_form.text_field :tipp1 %><br/>
<%= tipp_form.text_field :tipp2 %><br/>
<% end %>
This would reduce the bets to one bet on a match with ID of 5. This code however doesnt work.
What is the right way to solve this? Thanks in advance.