1

I have one RoR install and I am trying to use it for multiple websites. I want to use one RoR install because all the websites are similar (need to share same models) and need to be managed by the one admin namespace. My basic file structure is something like:

app
..controllers
....admin_namespace
....website1_namespace
....website2_namespace
..models 
....admin_namespace
....website1_namespace
....website2_namespace
..views
....admin_namespace
....website1_namespace
....website2_namespace

Does anyone know how I could point domain names to separate namespaces and remove the namespace from the url? I.e.

 www.admin.com -> points to /admin_namespace route
 www.website1.com -> points to /website1_namespace route
 www.website2.com -> points to /website2_namespace route

Using something like PHP, normally you would use Virtual Hosts to point different server names to different folder locations, but the problem I am running into is that you have to point all websites to app_name/app/public.

4

1 回答 1

0
scope module: 'admin', as: :admin, constraints: {domain: /admin.com/} do
  resources :pages
end

scope module: 'website1', as: :website1, constraints: {domain: /website1.com/} do
  resources :pages
end

这就是我最终做的事情,其中​​ domain: 采用正则表达式。谢谢。

于 2013-07-16T22:24:30.073 回答