【发布时间】:2014-08-17 21:40:46
【问题描述】:
我无法为子域设置根路径。
这是我的routes.rb 部分:
constraints subdomain: 'blog' do
scope :module => "blog", :as => "blog" do
resources :posts
end
end
root 'statics#index'
当我访问blog.example.com 时,我得到了static#index 操作响应,并在访问blog.example.com/posts 时得到posts#index。
我想为 blog.example.com 设置指向 posts#index 的根路径。
对此没有影响:
match '/' => 'posts#index', :constraints => { :subdomain => 'blog' }, via: [:get]
【问题讨论】:
-
您关心您的 routes.rb 文件中的顺序吗? Rails 将采用第一个匹配的路线。所以总是在在受限路线之后放置更多一般路线
-
是的,例如,'main' root 是 routes.rb 中的最后一条记录
标签: ruby-on-rails ruby-on-rails-4 routes subdomain