Am having a table with quetion_id , nominees and vote_count. In which
the values for question_id and nominees are prepopulated from other
tables with vote_count as zero.
If the users select some nominees the vote count should be incresed by
one. The problem is How to connect the question_id and nominees like for
this question_id this nominee is selected .
can some one give example for this situation..
If your table looked like:
Then a voting page could populate a droplist with the ids and names of
the nominees (the default should be something other than the first
nominee to reduce 'laziness bias' in the results). The user chooses an
entry and submits.
The controller then takes the post, grabs the question_id, selected
nominee id and updates the vote_count for that record.
You could go another route an populate a form with radiobuttons, one per
nominee, but you'll need to read up on radiobuttons in forms for Rails
as you code is a bit more involved (you'll be passing an array to the
form, and pulling the one 'selected' option out of that list in your