K guys, so I created this up / down vote script (basically, like here in stackoverflow), and I'm trying to add Ajax to it so that the page does not reload every time you vote,
I have two controllers, one of which is called grinders, and one is called voting. (Grinding machines are mostly messages)
So, here is the index of all the crushers (looks like this) 
and here is the code for this page.
</head> <body> <h1>Listing grinders</h1> <%= render(:partial => "grinders/grinders")%> <br /> <%= link_to 'New grinder', new_grinder_path %> </body> </html>
and this is what I have in the views / grinders / _grinders.erb
<% @grinders.each do |grinder| %> <div id="main"> <div style="float:left; height:80px; width:50px"> <div class='up'> <% form_for(@vote, :remote => true) do |u|%> <%= u.hidden_field :grinder_id, :value => grinder.id %> <%= u.hidden_field :choice, :value => "up" %> <%= image_submit_tag("http://i13.photobucket.com/albums/a287/Rickmasta185/arrow-small-green-up.png", :class => 'create') %> <% end %> </div> <center><%= grinder.votes_sum %></center> <div class='down'> <% form_for(@vote, :remote => true) do |d|%> <%= d.hidden_field :grinder_id, :value => grinder.id %> <%= d.hidden_field :choice, :value => "down" %> <%= image_submit_tag("http://i13.photobucket.com/albums/a287/Rickmasta185/arrow-small-red-down.png", :class => 'create') %> <% end %> </div> </div> <div class='box' >"<strong>It grinds our gears </strong><%=h grinder.grinder %>"</div> </div> </div> <% end %>
But every time I try to vote for him, I get the following error:
You have zero if you did not expect this! Perhaps you were expecting an array instance. Error evaluating nil.each
I tried a lot of things and I just can't get it to work! (Enlarged screenshot - http://grab.by/7bgb )
Any help? If you need more information, just ask!