【发布时间】:2012-02-26 18:16:02
【问题描述】:
我正在实施一个多租户 RoR 应用程序。使用路径中的第一段作为租户标识符而不是子域来标识租户。我的理解是getsatisfaction.com 实现了这种多租户路由。例如:
http://myapp.com/tenant1/resource 而不是http://tenant1.myapp.com,http://tenant2.myapp.com
我希望实现以下路由行为
get the tenant part from myapp.com/segement1/resource
if [segment1] has an entry in our db as a tenant
then set base_url as [http://myapp.com/segment1], and do the route lookup for /resource
else
set base_url as [http://myapp.com/] and do the route lookup for /segment1/resource
为了说明
http://myapp.com/login will not match any tenant, hence will login to the site
http://myapp.com/org1/tasks will match a tenant named org1, get the 'tasks' of org1
http://myapp.com/tasks will not many any tenant, get the task of all orgs
我尝试阅读 RoR routes.rb、url rewrite、apache 但无法找出最好的方法。关于如何实现这一点的任何指示?
【问题讨论】:
-
您是否找到了解决问题的通用方法?我也面临同样的问题,也想避免使用子域
标签: ruby-on-rails apache multi-tenant