I have a button in a partial that I want to send to the create method in my video_votes controller. The partial is in the video_votes view directory but is rendered into another partial which resides in the video view directory. My first question is, do I need to specify both the controller and action or just the action? Here’s the button:
<%= button_to "+1", { :action => "create", :id => @video.id, :type => "up" }, :remote => true %>
Second, I’m not sure what id I should be passing to the button. The video model has_many video_votes, and the video_votes belong to video.
Keep in mind that I don’t know your exact route(I guessed on the video_votes_path), but run
rake routesin the command line and set it to the one that points to the create action in the video_votes controller. You can pass in the video object to represent the id.