To retrieve the root domain within the Rails framework, use the following method:
request.domain
Given the following GET request:
http://www.example.com/users/1/edit
The above method will retrieve: example.com
Caveat: This will not work within your models.