Forum: Ruby on Rails How to pass additional get parameters using button_to?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8aa631c31b282b1809e95fac5db129d0?d=identicon&s=25 Dennis T. (Guest)
on 2009-03-05 18:32
(Received via mailing list)
A google search only turned up a few posts with the same problem, but
no answer...

Problem:

<%= button_to("New user", new_user_path(:testvar1 =>
"test1", :testvar2 => "test2"), :method => :get) %>

generates:

<form method="get" action="/users/new?
testvar1=test1&amp;testvar2=test2" class="button-to"><div><input
type="submit" value="New user" /></div></form>

Which doesn't work as browsers strip the get parameters off the uri.
Shouldn't the button_to-helper generate the get parameters as hidden
tags when using :method => :get?

Like this?

<form method="get" action="/users/new" class="button-to"><div><input
type="submit" value="New user" /></div><input type="hidden"
name="testvar1" value="test1"><input type="hidden" name="testvar2"
value="test2"></form>


Is this possible or are there another solution when using button_to?
This topic is locked and can not be replied to.