Forum: Ruby on Rails routes,maps, something_url, some simple questions i am sure.

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.
3d1a70ebd35ac970e009e01599603b46?d=identicon&s=25 koloa (Guest)
on 2007-02-15 16:12
hi,
i just started learning how to custimize my urls but i have a few
questions that im sort of unsure about.

first. if i do this.

map.detail "nj/:id"

in my view for controller 'nj' i can do something like this?

 <%= link_to ("show me details", detail_url(something.id)) %>

is this the same as calling link_to like this?

<%= link_to ("show me details", "localhost:3000/nj/" + something.id) %>


what is the difference between defining map like

map.detail :action => detail, :controller => nj

vs

map.connect "nj/detail" :action => detail, :controller => 'nj'
70225136eacd3d870f64e03bff678655?d=identicon&s=25 Russell Norris (Guest)
on 2007-02-15 16:20
(Received via mailing list)
As far as your link_to usage, yes. They're the same. The named route is
easier to maintain codewise but a little slower [at least in the olden
days]
than writing it out by hand like you do in the second example. The
difference between those last map.connect and map.details is 1.
map.detailscreates a named route where
map.connect doesn't and 2. You'll need to add the mapping "nj/:id" to
map.detail.

RSL
3d1a70ebd35ac970e009e01599603b46?d=identicon&s=25 koloa (Guest)
on 2007-02-15 16:29
thanks rsl, its clear now.

tried to look up something_url in the rails api, but didnt know what
title to look under. wasnt sure if its an extension of url_for.
This topic is locked and can not be replied to.