when i 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,
<% count = 1 %>
<% for voting in @voting %>
<% 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
updates every record adding one to the previous value. Your “if
voting.question…” encloses only the line below it (It appears that
<% end %> is missing.
On 3 ago, 11:01, Tamilselvi Srinivasan <rails-mailing-l…@andreas-
sorry,i have missed to paste the <%end%> in the post.
actually i need to compare the selected nominee with the available
nominees .
if both are equal then i need to update the vote_count. so only i
updated the model in view…
Eddy J. wrote:
Why are you doing model updating in the view? Can you post the
corresponding controller code?
You use a loop to read every record in your table, and inside that
loop, the line:
updates every record adding one to the previous value. Your “if
voting.question…” encloses only the line below it (It appears that
<% end %> is missing.
On 3 ago, 11:01, Tamilselvi Srinivasan <rails-mailing-l…@andreas-