Is there a way for me to have subdomains on my rails project?

For example, if I create a post, i get this URL- http://www.localhost:3000/posts/####
(what ever number)

How can I make the route so that it is---- title.localhost:3000/

title is a field of my posts.

Is there a way to do that? OR if that's too complicated, then how do i
replace the /posts/##### with /post.title?


You can do that with request.subdomains inside a controller. See

If you want to "change" your primary key (or the key used for search)
try with to_param. See


Franco Catena.