I have a table with question_id
, nominees
and vote_count
in which the values for question_id
and nominees
are populated from other tables with vote_count
as zero.
ex:
question_id nominees vote_count
1 tamil 0
1 selvi 0
2 aaaa 0
3 qqqq 0
3 wwww 0
If the users select a nominee, then the vote count for the particular nominee should be updated like this.
question_id nominees vote_count 1 tamil 1 1 selvi 0 2 aaaa 1 3 qqqq 0 3 wwww 1
am implementing this as follow,
<% if voting.question_id.eql?(count) %> <%= radio_button( count, voting.vote_count, :id => voting.nominees ) %> <%= voting.nominees %>
<% voting.update_attribute('vote_count', voting.vote_count+1 ) %> <% end %>
but it updates vote_count for all the nominees like
question_id nominees vote_count 1 tamil 1 1 selvi 1 2 aaaa 1
3 qqqq 1 3 wwww 1
any help on this...