Routes question

Is it possible to have a RoR application serving two different websites/domain names?

I'm creating a simple discussion group application... but I'd like my RoR instance to be shared between these domains.

So, in my routes... can i pass down to my application what the domain name is?

Entries in my database can then have a domain field!

Ah, thanks for the info Joe

I’ve been playing around with the new ActiveResource. Initially thought I would determine the current domain in the routes.rb, but looks like it’s best done in the controllers.

Will have to do a bit more thinking. Still a newbie to rails, so hopefully I haven’t bitten off more than I can chew :slight_smile:

We did it using a before_filter in the ApplicationController and added a table of domains to our database. That way, we can store basic info about the site in the database. Something like this:

before_filter :site

def site #### get the site from the session, or from the domain if it hasn’t been loaded yet. logger.warn(“The Domain is #{request.domain}”) session[:site] = Site.find_by_domain(request.domain ) unless (session[:site] && session[:site].domain == request.domain) @site = session[:site] end

-ron