Forum: Ruby on Rails Restful AND Pretty Urls

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.
4c70286747864c04c5c1f9b0aa380590?d=identicon&s=25 Joe Blow (joeblow)
on 2008-11-07 19:35
Is there anyway to have restful AND pretty urls?

For example:

map.resources :users

Would give us nice little helpers
users_url
new_user_url
edit_user_url(@user)

etc.

But what if I wanted my urls to be pretty like

Instead of

http://www.mysite.com/users/

I want

http://www.mysite.com/list_all_my_damn_users

Basically I want the nice little helpers AND pretty urls.
941120dac2e97cf8bc1cbe0216159104?d=identicon&s=25 David Trasbo (datra)
on 2008-11-07 19:52
Joe Blow wrote:

<snip>

> But what if I wanted my urls to be pretty like
>
> Instead of
>
> http://www.mysite.com/users/
>
> I want
>
> http://www.mysite.com/list_all_my_damn_users
>
> Basically I want the nice little helpers AND pretty urls.

Let me start out by saying that I actually think your "pretty" url is
uglier than the "ugly" url... (: Anyway, I don't think Rails explicitly
provides the possibility to completely redefine the look and feel of
urls (unless you'ld use map.connect manually that doesn't provide any
helper methods), but you can rid of the id's by using the to_param
method in your ActiveRecord models as described in Railscasts #63 "Model
Name in URL" (http://railscasts.com/episodes/63-model-name-in-url).

Hope that helps...
This topic is locked and can not be replied to.