Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 UJS: Passing in params when using link_to

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 %> 
like image 710
meow Avatar asked Dec 07 '10 03:12

meow


1 Answers

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.

like image 171
Fredrik Boström Avatar answered Sep 24 '22 21:09

Fredrik Boström