11175
(-- --)
1
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.
11175
(-- --)
2
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:
<a href="/plans/new?id1=2&id2=3">New plan</a>
And the #new action will see both params[:id1] and params[:id2]
11175
(-- --)
3
Mark Bush 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) %>
11175
(-- --)
4
Still I am getting nil value for the id2
Mark Bush wrote:
11175
(-- --)
5
Vidya Ramachandren wrote:
Still I am getting nil value for the id2
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?
Ajit
(Ajit)
6
Hi
Try this
link_to("abcabcabd", :controller=>'controller', :action=>'action', :id=>
123, :show=>"true")
it will create a link something like :
<a href="controller/action/123?show=true">abcabc</a>
on next page<%= params[:id]%> will be equal to 123 and <%=
params[:show]%> equal to true
i hope it will help
Ajit