Link_to restfully

Should be a simple solution for this:

I have:
<%= link_to “Add Address”, order_new_addressbook_path(@order) %>
which generates
Add Address

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

so… where do I put the :address_type => 2 part? :slight_smile:

Thanks!

On 6/29/07, Dave C. [email protected] wrote:

put them. The end result URL that I’m looking for is:

Add Address

so… where do I put the :address_type => 2 part? :slight_smile:

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

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

Add
Address

so… where do I put the :address_type => 2 part? :slight_smile:

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.
[email protected]
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)

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 :wink:

-Rob

Rob B.
[email protected]
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)

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!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs