Forum: Ruby on Rails link_to restfully

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.
3bfb45030a0bbd1ebb4714b8b2f545a8?d=identicon&s=25 Dave C. (pezdude)
on 2007-06-29 04:16
Should be a simple solution for this:

I have:
<%= link_to "Add Address", order_new_addressbook_path(@order) %>
which generates
<a href="/orders/23222/addressbooks/new">Add Address</a>

I want to pass in additional parameters, yet cant figure out where to
put them. The end result URL that I'm looking for is:

<a href="/orders/23222/addressbooks/new?address_type=2">Add Address</a>

so... where do I put the :address_type => 2 part? :-)

Thanks!
739e2894aaaa2e2da1627dd5d819fba7?d=identicon&s=25 Daniel -. (liquid)
on 2007-06-29 04:21
(Received via mailing list)
On 6/29/07, Dave Coleman <rails-mailing-list@andreas-s.net> wrote:
> put them. The end result URL that I'm looking for is:
>
> <a href="/orders/23222/addressbooks/new?address_type=2">Add Address</a>
>
> so... where do I put the :address_type => 2 part? :-)
>
> Thanks!



I'd like to know this one too.  What I've done in that past is pass the
named route a hash.

order_new_addressbook_path( :order_id => @order_id, :address_type => 2 )

But I don't like having to supply specifically the :order_id part but I
can't seem to get it working otherwise.

Cheers
Daniel
Rob Biedenharn (Guest)
on 2007-06-29 04:23
(Received via mailing list)
On Jun 28, 2007, at 10:16 PM, Dave Coleman wrote:
> <a href="/orders/23222/addressbooks/new?address_type=2">Add
> Address</a>
>
> so... where do I put the :address_type => 2 part? :-)
>
> Thanks!

order_new_addressbook_path(:order => @order, :address_type => 2)

You have to use the hash options form to provide additional
parameters for the query string of the URL.

-Rob

Rob Biedenharn
Rob@AgileConsultingLLC.com
http://agileconsultingllc.com
--------------------------
"I sort of keep hoping that red herrings will steadilly come along,
to keep people busy; I get secret satisfaction when bad ideas take
hold and suck a lot of people in ... like Java."
-- Don Knuth, Things a Computer Scientist Rarely Talks About, p.16
(Stanford, California: CSLI Publications, 2001)
3bfb45030a0bbd1ebb4714b8b2f545a8?d=identicon&s=25 Dave C. (pezdude)
on 2007-06-29 04:32
> order_new_addressbook_path(:order => @order, :address_type => 2)
>
> You have to use the hash options form to provide additional
> parameters for the query string of the URL.
>

Rob, Daniel's example worked, yours did not.
Did you mean to say order_id?

Thanks for the quick reply!
Rob Biedenharn (Guest)
on 2007-06-29 04:54
(Received via mailing list)
On Jun 28, 2007, at 10:32 PM, Dave Coleman wrote:
>> order_new_addressbook_path(:order => @order, :address_type => 2)
>>
>> You have to use the hash options form to provide additional
>> parameters for the query string of the URL.
>>
>
> Rob, Daniel's example worked, yours did not.
> Did you mean to say order_id?
>
> Thanks for the quick reply!

Yes, of course I did!  (just want to make sure you were paying
attention ;-)

-Rob

Rob Biedenharn
Rob@AgileConsultingLLC.com
http://agileconsultingllc.com
--------------------------
"I sort of keep hoping that red herrings will steadilly come along,
to keep people busy; I get secret satisfaction when bad ideas take
hold and suck a lot of people in ... like Java."
-- Don Knuth, Things a Computer Scientist Rarely Talks About, p.16
(Stanford, California: CSLI Publications, 2001)
This topic is locked and can not be replied to.