2010-02-23 3 views
0

현재 내 사이트의 하위 도메인 및/또는 이름이 지정된 모든 트래픽을 처리기라고하는 외부 및 컨트롤러라는 컨트롤러로 보냅니다.도메인/하위 도메인 라우팅 및 이름 공간 컨트롤러 사용

정말 지저분 해졌고 정리하고 싶습니다. 모든 외부 요청을 정상적인 레일 방식으로 처리하고 싶습니다. ": controller/: action/: id"그러나 자신의 폴더에 이러한 컨트롤러가 필요하므로 메인 컨트롤러에 중복이 없습니다.

not_domain_regex = Regexp.new('\A(?!(' + SiteConfig::domain.gsub('.', '\.') + '))', true) 
    is_domain_regex = Regexp.new('\A((' + SiteConfig::domain.gsub('.', '\.') + '))', true) 
    map.connect(
    '*path', 
    :controller => 'external', 
    :action => 'handler', 
    :conditions => { 
    :domain => not_domain_regex 
    } 
) 
    map.connect(
    '*path', 
    :controller => 'external', 
    :action => 'handler', 
    :conditions => { 
    :domain => is_domain_regex, 
    :subdomain => /([a-z0-9\-\_]{1,100}[^www])/i 
    } 
) 

나는 완전히 손실입니다 : /controllers/external/controller_name.rb

는 여기에 지금까지 무슨이다. 그래서 같을 것이다 기능을 가지고 싶다 :

map.connect(
    ':controller/:action/:id', 
    :namespace => 'external', 
    :conditions => { 
    :domain => not_domain_regex 
    } 
) 

답변