Hi everyone! I have a view that outputs several versions of the same
form, and I want the user to be able to fill all of them out, and hit
submit once. When that happens, I want each form entry to be submitted
into a database table. I just don''t know how to do that.
Here''s what I
have now:
<form action="create" method="post">
<table>
<% @gameweek.each do |game| %>
<tr>
<td><%= game.home_team.name %></td>
<td><%= text_field ''guess'',
''hometeam_score'' %>
<td><%= text_field ''guess'',
''visitingteam_score'' %></td>
<td><%= game.away_team.name %></td>
<td><%= game.gameweek %>
</tr>
<% end %>
</table>
<%= submit_tag "Submit" %>
</form>
And the controller:
def create
@guess = Guess.new(params[:guess])
if @guess.save
flash[:notice] = ''<p class="success">Your game
has been
saved.</p>''
redirect_to :controller => ''guess'', :action =>
''index''
else
render :action => ''new''
end
end
I don''t know how to tell the controller to take each of those tr forms
and process them seperately. I''m sure this is easy, but I''ve
never done
something like this before.
Thanks!
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---