# Link\_to restfully

**URL:** <https://www.ruby-forum.com/t/link-to-restfully/108115>\
**Category:** Rails\
**Created:** [June 29, 2007, 4:16am UTC](https://www.ruby-forum.com/t/link-to-restfully/108115 "2007-06-29T04:16:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pezdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@pezdude](https://www.ruby-forum.com/u/pezdude)\
**Post date:** [June 29, 2007, 4:16am UTC](https://www.ruby-forum.com/t/link-to-restfully/108115/1 "2007-06-29T04:16:44Z")

</div>

Should be a simple solution for this:

I have:  
\<%= link\_to “Add Address”, order\_new\_addressbook\_path(@order) %\>  
which generates  
[Add Address](https://www.ruby-forum.com/orders/23222/addressbooks/new)

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:

[Add Address](https://www.ruby-forum.com/orders/23222/addressbooks/new?address_type=2)

so… where do I put the :address\_type =\> 2 part? 🙂

Thanks!

---

<div class="post-metadata">

**Author:** ![pezdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@pezdude](https://www.ruby-forum.com/u/pezdude)\
**Post date:** [June 29, 2007, 4:21am UTC](https://www.ruby-forum.com/t/link-to-restfully/108115/2 "2007-06-29T04:21:18Z")

</div>

On 6/29/07, Dave C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> put them. The end result URL that I’m looking for is:
> 
> [Add Address](https://www.ruby-forum.com/orders/23222/addressbooks/new?address_type=2)
> 
> 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

---

<div class="post-metadata">

**Author:** ![pezdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@pezdude](https://www.ruby-forum.com/u/pezdude)\
**Post date:** [June 29, 2007, 4:23am UTC](https://www.ruby-forum.com/t/link-to-restfully/108115/3 "2007-06-29T04:23:19Z")

</div>

On Jun 28, 2007, at 10:16 PM, Dave C. wrote:

> [Add  
> Address](https://www.ruby-forum.com/orders/23222/addressbooks/new?address_type=2)
> 
> 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 B. removed\_email\_address@domain.invalid [http://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)

---

<div class="post-metadata">

**Author:** ![pezdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@pezdude](https://www.ruby-forum.com/u/pezdude)\
**Post date:** [June 29, 2007, 4:54am UTC](https://www.ruby-forum.com/t/link-to-restfully/108115/4 "2007-06-29T04:54:22Z")

</div>

On Jun 28, 2007, at 10:32 PM, Dave C. 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 B. removed\_email\_address@domain.invalid [http://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)

---

<div class="post-metadata">

**Author:** ![pezdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@pezdude](https://www.ruby-forum.com/u/pezdude)\
**Post date:** [June 29, 2007, 4:32am UTC](https://www.ruby-forum.com/t/link-to-restfully/108115/5 "2007-06-29T04:32:22Z")

</div>

> 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!
