Problem in passing 2 params

I am trying to pass 2 parameters to the ‘new’ action in the
plans_controller, something like this.

  "new_plan_path+"?id1=1&id2=3"

Only ‘id1’ is passed and the “&” symbol is rewritten as ‘&’, hence
‘id2’ is not received using params[:id2] in new method.

Somebody suggest an alternate please…

Thanks in advance.

Vidya Ramachandren wrote:

  "new_plan_path+"?id1=1&id2=3"

Only ‘id1’ is passed and the “&” symbol is rewritten as ‘&’, hence
‘id2’ is not received using params[:id2] in new method.

Use something like:

<%= link_to ‘New plan’, url_for(:action => :new, :id1 => 2, :id2 => 3)
%>

This will create the tag:

New plan

And the #new action will see both params[:id1] and params[:id2]

Mark B. wrote:

Use something like:

<%= link_to ‘New plan’, url_for(:action => :new, :id1 => 2, :id2 => 3)
%>

Actually, this is better as:

<%= link_to ‘New plan’, new_plan_path(:id1 => 2, :id2 => 3) %>

Still I am getting nil value for the id2 :frowning:

Mark B. wrote:

Mark B. wrote:

Use something like:

<%= link_to ‘New plan’, url_for(:action => :new, :id1 => 2, :id2 => 3)
%>

Actually, this is better as:

<%= link_to ‘New plan’, new_plan_path(:id1 => 2, :id2 => 3) %>

Vidya Ramachandren wrote:

Still I am getting nil value for the id2 :frowning:

I’ve checked this against Safari, Firefox and IE and all pass the params
correctly. (This is with Rails 2, but that shouldn’t matter.)

Can you look at the web page source with the link on it and post the
link text and also the parameters from your log file from selecting the
link?

Hi

Try this

link_to(“abcabcabd”, :controller=>‘controller’, :action=>‘action’, :id=>
123, :show=>“true”)

it will create a link something like :

abcabc

on next page<%= params[:id]%> will be equal to 123 and <%=
params[:show]%> equal to true

i hope it will help

Ajit

On Mar 10, 8:39 am, Vidya Ramachandren <rails-mailing-l…@andreas-