9. 配置子域名
scope subdomain: 'admin' do
resources :posts
end
scope constraints: {subdomain: 'admin'} do
resources :posts
end
scope subdomain: 'admin', constraints: {subdomain: 'admin'} do
resources :posts
end
13年5月9日星期四
10. 配置子域名
scope subdomain: 'admin' do
resources :posts
end
> app.posts_url
=> "http://www.example.com/posts"
> Rails.application.routes.recognize_path("http://admin.example.com/posts")
=> {:action=>"index", :controller=>"posts"}
> Rails.application.routes.recognize_path("http://example.com/posts")
ActionController::RoutingError: No route matches "http://example.com/posts"
> Rails.application.routes.recognize_path("http://somesubdomain.example.com/posts")
ActionController::RoutingError: No route matches "http://somesubdomain.example.com/posts"
13年5月9日星期四