我正在实施多租户RoR应用程序。租户使用路径中的第一个段作为租户标识符而不是子域标识。我的理解是,getsatisfaction.com实现这种多租户行为。例如:基于路径的多租户RoR应用程序的URL路由
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
我试着读了回报率的routes.rb,网址重写,阿帕奇,但无法找出最好的方式来做到这一点。任何关于如何实现这一点的指针?
您是否得到了针对您问题的通用解决方案?我面临同样的问题,并希望避免子域以及 – scanales 2013-03-05 00:06:32