2

Would like to pass some parameters to the _path for link_to or redirect_to. For example, link_to 'show', customers_show_path(params[:id]) will show the customer with id=params[:id].

What do I do if I want to pass another parameter such as session[:user_id] into the show? Does link_to 'show', customers_show_path(params[:id], :user_id => session[:user_id]) work (retrieve session[:user_id] with params[:user_id] in show)?

Any suggestions?

halfer
  • 19,824
  • 17
  • 99
  • 186
user938363
  • 9,990
  • 38
  • 137
  • 303

1 Answers1

4

Try this:

'customers', :action => "show", :id => 1, :user_id => 2%>

Didn't check, but should work :D

Following are the similar questions:

pass parameter by link_to ruby on rails

rails - Pass id parameter on a link_to

passing a parameter to the link_to method

http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/57a63381c8bdc6a5?pli=1

halfer
  • 19,824
  • 17
  • 99
  • 186
sameera207
  • 16,547
  • 19
  • 87
  • 152