How to generate this URL

I’m stumped trying to generate an URL for a working route. I’ve this
route definition:

map.connect ‘foo/:foo_id/propose_something/:zap_id’,
:controller => “foo”,
:action => “propose_something”

When I browse to this url:
http://localhost:3000/foo/2/propose_something/5,
my propose_something method gets invoked with the correct params
hash. So one would think that all is good, but I’m stuck trying to
generate the corresponding URL to pass to link_to.

I would think that this would do it:
url_for(:controller => “foo”, :action => ‘propose_something’, :foo_id
=> 1, :zap_id => 13)

But this generates this URL:
http://localhost:3000/foo/propose_something?foo_id=1&zap_id=13

To work around this, I’ve constructed the string manually, but that
feels nasty in all sorts of ways…

Can someone point out what the heck I’m doing wrong?

Thanks,
east

On Fri, 2010-02-26 at 17:44 -0800, east wrote:

generate the corresponding URL to pass to link_to.

Can someone point out what the heck I’m doing wrong?


url_for(:controller => “foo”, :action => (’/’ + :foo_id +
‘/propose_something’), :zap_id => 13)

You might not need the parens but it tends to help me spot what the
intent was right away.

That said, I probably would rethink my ‘routes’ and use routes and
methods that tended towards standardization and have my methods parse
the params.

Craig


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.