SCENARIO My app has two types of accounts, personal and business. Both accounts will have some similar controller/action names, however, they will behave differently. Additionally, the business account will have many more controllers not found in the personal account. QUESTION How do I partition my app so that I can isolate personal and business controllers under under a single or dual subdomain configuration? OPTION 1 Create two subdomains for each account, personal.domain.com and business.domain.com. If I take this approach, I see trouble down the road when other parts of the app need to link back to the user''s account. At some point a decision will have to be made, is it personal.domain.com or business.domain.com? If possible, I was thinking that routes could be selected, in routes.rb, based on the session data, (e.g. check for personal or business account)? OPTION 2 Create a single account domain, my.domain.com, and then select the correct controller/action for the user''s account in the ApplicationController. For example, in routes.rb (request routing plugin installed): map.with_options(:condition => {:subdomain => ''my''}) do |x| x.connect ''*path'', :controller => ''application'', :action => ''route_to_account'' end Then the ApplicationController::route_to_account will handle the controller/action routing to the personal or business controller/action contingent upon session data. If I take this approach, it seems I loose all the cool routing stuff, like named routes, and url variables in @params? What should I do? Any advice is greatly appreciated. -pachl -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On Oct 31, 8:52 am, "Starr" <snho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---