2
我有一个Rails 4.0应用程序,允许用户通过子域访问博客。我目前的路线是这样的:从Rails中的子域中排除所有其他资源
match '', to: 'blogs#show', via: [:get, :post], constraints: lambda { |r| r.subdomain.present? && r.subdomain != 'www' }
resources :foobars
现在,当我浏览到somesubdomain.example.com
我确实带到blogs
控制器动作的show
作用,符合市场预期。
当我导航到example.com/foobars
时,我可以按照预期访问foobars
控制器的index
操作。
不过,我只得到一个行为我不渴望: 当我浏览到somesubdomain.example.com/foobars
,我仍然可以访问foobars
控制器的index
行动。
有没有办法限制或排除所有资源,我不特别允许特定的子域(即somesubdomain.example.com/foobars
将不会工作,除非另有规定)。
谢谢!
谢谢。这正是我最终做的。 –