I am new to ROR, but am facing this problem: on the index page I have
<%= button_to 'Yes', { :action => 'vote', :id => poll.id, :user_answer => 'yes' }, :method => :post %>
when the user clicks Yes, the URL passed to the controller contains all the parameters explicitly for the user.
vote?id=1&user_answer=yes
in routes.rb I have:
match 'vote' => 'polls#vote', :via => :post
Any help is appreciated
edit: whole index.html.erb
Polls
<% @polls.each do |poll| %> <p> <%= poll.question %>? <%= button_to 'Yes', { :action => 'vote', :id => poll.id, :user_answer => 'yes' }, :method => :post %> (<%= poll.yes %>) / <%= button_to 'No', { :action => 'vote', :id => poll.id, :user_answer => 'no' }, :method => :post %> (<%= poll.no %>) </p> <% end %>
source share