views:

75

answers:

1

I have a view like this,

<% count = 1 %>
<% for voting in @voting %>
    <% if voting.question_id.eql?(count) %>
        <%= radio_button( count, voting.vote_count, :radio_id => voting.nominees  ) %>
        <%= voting.nominees %> 
    <% end  %>

    <% if voting.nominees.eql?(radio_id) %>
        <% voting.update_attribute('vote_count', voting.vote_count+1 ) %>
    <% end  %>
    <% count += 1 %>
<% end  %>

how can i compare the selected nominees with the existing one.

any help on this would be very useful...

+1  A: 

Some models and associations would be handy here. I suspect options_from_collection_for_select will be your best friend. Also look at increment.

askegg