Does ROR allow passing the chosen value from a drop down using
select_tag into link_to ?
Basically I want to do something like:
<%= select_tag( "name", options_for_select(%w{John Doe Jane })) %>
<%= link_to "Delete",
{ :controller => "myname", :action => "add",
:id => name },
:confirm =>
"Are you sure}?" %>
<% form_tag { :controller => "myname", :action => "add", :id => name },
"name"=>"jump" do %>
<%= select_tag ("name", options_for_select(%w{John Doe Jane }),
"onChange"=>"location=document.jump.menu.options[document.jump.menu.selectedIndex].value;",
"value"=>"GO") %>
<% end %>
<% end_form_tag %>
I am not sure that my way is correct. Maybe any reference from other
partner here?
Reinhart's suggestion should work if the user has javascript, but I'd
be wary of doing that, especially for a "delete" link...although
you're calling an "add" action...strange...
In general, link_to will render an <a href="..." ...>...</a>, and once
it's on the page, it's set. If you want a user to select something
from a box and use that value, use a form. If you don't like form
buttons, try somehow getting a link_to to use onClick=form.submit. I
know very little about javascript, so check with others on how to
accomplish that.