Forum: Ruby on Rails url_for or resource_url additional params?

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.
032fdb4cd4a3c65ebb77846dfa724679?d=identicon&s=25 Joe Noon (joenoon)
on 2007-08-01 21:39
(Received via mailing list)
if i want a link to book_url(@book), but i want to pass an additional
param, how to i do that?

i want it to result in something like http://localhost/books/1?foo=bar

this works, but seems hackish:

url_for(:controller => book_path(@book), :foo => "bar", :only_path =>
false)
Ef3aa7f7e577ea8cd620462724ddf73b?d=identicon&s=25 Rob Biedenharn (Guest)
on 2007-08-02 00:53
(Received via mailing list)
On Aug 1, 2007, at 3:38 PM, Joe Noon wrote:
> if i want a link to book_url(@book), but i want to pass an additional
> param, how to i do that?
>
> i want it to result in something like http://localhost/books/1?foo=bar
>
> this works, but seems hackish:
>
> url_for(:controller => book_path(@book), :foo => "bar", :only_path =>
> false)

book_url(:id => @book, :foo => 'bar')

You have to use the hash format even for the :id when you want to add
other parameters.

-Rob

Rob Biedenharn    http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
This topic is locked and can not be replied to.