I have a restful (scaffold generated) controller and model for Votes, I am simply trying to add a field into the view that when clicked, will create a new vote for a given car. It needs to be a POST, What's the way I should be doing this in rails?
<% @cars.each do |car| %>
<tr>
<td><%= button_to '+', {:controller => "votes", :action => "create"}, :car_id => car.id, :user_id=> session[:user_id] , :method=>:post %></td>
<td><%= car.votes.count %></td>
<td><%= car.name %></td>
<td><%= car.code %></td>
<td><%= car.album %></td>
<% end %>
Best Answer
This will make params[:car_id] and params[:user_id] available in VotesController create action.