Rails 3 UJS: Passing in params when using link_to

ruby-on-rails-3

Solution

You can pass parameters in the path function as part of the url. Something like:

<%= link_to "bleh", 
  like_path(:answer_id => 123, :add_param => 2), 
  :remote=> true , :method=> :post %>

# would result in something like
# yourapp.com/like/aswer/3?add_param=2

But I think you need to move away from the purely resource based path helper in this case. Check the documentation for ideas.

Problem

How to we pass in additional params besides the ID ``` #we want to pass in additional params as well <%= link_to "bleh", like_path(answer), :add_param=>2 , :remote=>"true" ,:method=>:post %> ```

Original source