rails多域名配备
rails多域名配置多域名配置我认为最好是通过程序实现。先给出部分代码:#abc.def.xxx.computs request.url#h
rails多域名配置
多域名配置我认为最好是通过程序实现。先给出部分代码:
#abc.def.xxx.com puts request.url#http://abc.def.xxx.com puts request.domain#xxx.com puts request.subdomain[0]#abc puts request.subdomain[1]#def puts request.user_agent#Mozilla/5.0 (X11; Linux i686) class ApplicationController < ActionController::Base protect_from_forgery before_filter :query_user_by_domain private def query_user_by_domain if request.domain!="diancai.la" @user = User.where(["domain = ?", request.domain]).first end endend
下面的是转自http://lightyror.thegiive.net/2006/12/rails-subdomain.html
AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1
。RailsTip 有一篇 Building A Multi-Site Application,裡面介紹可以使用 DHH 寫的 Subdmain 的 plugin AccountLocation 來做到這件事情。安裝方式是
script/plugin install http://dev.rubyonrails.org/svn/rails/plugins/account_location/
然後在程式裡面使用
include AccountLocation
其他相关文章:
http://railstips.org/blog/archives/2006/11/13/building-a-multi-site-supported-application/
http://www.iteye.com/topic/39836