# Subdomains

**URL:** <https://www.ruby-forum.com/t/subdomains/190325>\
**Category:** Rails\
**Created:** [June 17, 2010, 6:03pm UTC](https://www.ruby-forum.com/t/subdomains/190325 "2010-06-17T18:03:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidz101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@davidz101](https://www.ruby-forum.com/u/davidz101)\
**Post date:** [June 17, 2010, 6:03pm UTC](https://www.ruby-forum.com/t/subdomains/190325/1 "2010-06-17T18:03:17Z")

</div>

hi,

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/####](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?

THANKS!

---

<div class="post-metadata">

**Author:** ![davidz101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@davidz101](https://www.ruby-forum.com/u/davidz101)\
**Post date:** [June 17, 2010, 11:39pm UTC](https://www.ruby-forum.com/t/subdomains/190325/2 "2010-06-17T23:39:21Z")

</div>

You can do that with request.subdomains inside a controller. See  
[http://api.rubyonrails.org/classes/ActionController/Request.html#M000526](http://api.rubyonrails.org/classes/ActionController/Request.html#M000526)

If you want to “change” your primary key (or the key used for search)  
try with to\_param. See

> **[ActiveRecord::Base](https://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001840)**
>
> Active Record Active Record objects don't specify their attributes directly, but rather infer them from the table definition with which they're linked.

Regards.

Franco C…
