zabumba
zabumba

Reputation: 12402

Custom profile URL or routing

Rails 3.2 app

How do I access (read, show action) a resource with a custom URL?

Typically we would do this (REST):

http://localhost/entities/23

and this will show the data for Entity with id = 23

How can have it going to the same page when using accessing this way:

http://127.0.0.1/directory/[entity-name]

Is that something I can code in my routes.rb file?

Note that I want to replace spaces in Entity name with '-' in the URL.

Cheers,

joel

Upvotes: 0

Views: 48

Answers (1)

membLoper
membLoper

Reputation: 2002

What you're looking for is slugged or human-friendly urls.

Friendly ID is a great gem which can help you create slugged urls.

Upvotes: 1

Related Questions