Subdomains, Session Data, & Routing

Option #2 definately. #1 would be full of headaches. You could just map 'account/personal' and 'account/business' to the different controllers. I don't see why you would loose any routing abilities.

Starr

Option #2 definately. #1 would be full of headaches. You could just map 'account/personal' and 'account/business' to the different controllers.

So my next question, where exactly would I map my controller, in routes.rb or ApplicationController (as I mention in Option#2)?

When the request comes into the routing code, my only way of determining if a user is a business or personal account is via sessions[:business_id] (it will be nil for personal and set for business). So how could I get at this session variable? Is there another way of doing this?

I don't see why you would loose any routing abilities.

If I take the option#2 approach, I wouldn't be able to setup named routes like the following:

map.with_options(:condition => {:subdomain => 'my'}) do |x|   if session[:business_id]     # business account mappings ...     biz.connect ':action/:id', :controller => 'account/business'   else     # personal account mappings ...     per.connect ':action/:id', :controller => 'account/personal'   end end

I want to take approach #2, but not sure how to do this using a single subdomain that maps to two backend controllers. My only differentiator between the two accounts is the session variable "business_id".

Is there a way to get at session data in config/routes.rb? If so, I think I can acheive option#2!

I'm very new at Rails so a good explaination will be greatly appreciated. This is my first time using Rails; I am rewriting an PHP app.

-pachl