Can someone check what's wrong with this code?
I'm sorry for the title nad no idea what to name if, anyone mind changing it for me?
Hey guys, I'm not sure if I'm able to do this or not in rails, but I tried it just to see if it'll work or not, hopefully someone understands what I'm trying to do
<% @grinders.each do |grinder| %>
<div id="main">
<div style="float:left; height:80px; width:50px">
<div class='up'>
<% form_for(@vote) do |f| %>
<%= f.hidden_field :grinder_id, :value => @grinder.id %>
<%= f.hidden_field :type, :value => "up" %>
<%= f.submit 'Create' %>
<% end %>
</div>
<center><%=h grinder.votes_up - grinder.votes_down %></center>
<div class='down'>
<% form_for(@vote) do |f| %>
<%= f.hidden_field :grinder_id, :value => @grinder.id %>
<%= f.hidden_field :type, :value => "down" %>
<%= f.submit 'Create' %>
<% end %>
开发者_JAVA技巧 </div>
</div>
<div class='box' >"<strong>It grinds our gears </strong><%=h grinder.grinder %>"</div>
</div>
</div>
<% end %>
So I tried it out, and I'm getting this error, http://grab.by/6DbH Any help?
It looks like @vote
hasn't been initialized. Add the following to the index method in grinders_controller.rb
@vote = Vote.new
精彩评论