【问题标题】:Domain / Subdomain routing and using namespaced controllers域/子域路由和使用命名空间控制器
【发布时间】:2010-02-23 18:26:10
【问题描述】:

我目前正在将所有子域和/或命名到我的站点的流量引导到一个名为 external 的控制器和一个名为 handler 的方法。

这变得非常混乱,我想清理它。我希望以正常的 rails 方式处理所有外部请求“:controller/:action/:id”但是,我希望这些控制器在它们自己的文件夹中,因此我的主控制器中没有重叠。 /controllers/external/controller_name.rb

这是我目前所拥有的:

  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
    }
  )

我完全迷路了。所以我想拥有如下所示的功能:

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

【问题讨论】:

    标签: ruby-on-rails request


    【解决方案1】:
    猜你喜欢
    • 2014-11-08
    • 2022-08-16
    • 2012-03-07
    • 1970-01-01
    • 1970-01-01
    • 2015-07-05
    • 2014-07-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多