Topic: Parameter forwarding problem. Thanks

I have a problem for a long time.
for example:
I have a code like this:

<%=link_to(image_tag("Interface/buttonCurrntPrj.gif",:border=>0), url_for(:controller=>'projects', :action=>'displaycurrentprj', :type_id=>'0', :status_id=>'1'))%>

It is obvious that I am creating link to an button and when the button is clicked, I need to pass two parameters (here, one is type_id and the other one is status_id) to my "projects" controller so I can quary the database, assign value to variable "@projects" and then display the result with "list.rhtml" view of "projects".

Is this code correct? It does not work.
Could you please tell me how to transfer multiple parameters to controllers using "link_to" function like above?


Re: Parameter forwarding problem. Thanks

The above should work, are you unable to access the variables using params[:type_id] and params[:status_id] in the resulting controller action? View the HTML source of the link and see if the parameters are in the URL. Next, view the development.log file and see if they are being received properly.

BTW, the call to url_for here isn't necessary, link_to will automatically call it.

<%= link_to image_tag("Interface/buttonCurrntPrj.gif",:border=>0), :controller=>'projects', :action=>'displaycurrentprj', :type_id=>'0', :status_id=>'1' %>

Railscasts - Free Ruby on Rails Screencasts

Re: Parameter forwarding problem. Thanks

Wow, I made a stupid mistake that is not ralated to the code.
Thank you ryanb. You are right, the code is right.

I would anyway like to share my "experience" with other developers.
The mistake was caused by the defination of "displaycurrentprj" in the "projects" controller.
I still used "list". I forgot to change the name from "list" to "displaycurrentprj"

Sorry for the mistake. However, it is an experience.
Thank you for your fast response and accurate instruction