我有一个问题,我有一个管理子域设置在路由如下:
constraints :subdomain => 'admin' do
scope :module => "admin" do
match 'articles/:id/', :to => 'articles#show'
resources :articles, :events do
collection do
post :update_attribute_on_the_spot
end
end
root :to => "dashboard#index"
end
end
然后在主站点的文章中,我有:
resources :articles, :events, :george
match '/:year/:month/:day/:slug', :to => 'articles#show', :as => "article", :constraints => {:year => /d{4}/, :month => /d{1,2}/, :day => /d{1,2}/ }
match '/event/:year/:month/:day/:slug', :to => 'events#show', :as => "event", :constraints => {:year => /d{4}/, :month => /d{1,2}/, :day => /d{1,2}/ }
我想知道我如何确保当管理子域路由生效时不使用主站点路由,截至目前,当进入管理部分文章显示映射到主站点路由时,因此管理路由将无法发挥作用,除非该路由被删除。
如果有人能告诉我解决这个问题的最好方法,那就太好了。
谢谢!
我没有意识到用:as声明一些东西会如此简单地覆盖任何其他路由:
match '/:year/:month/:day/:slug', :to => 'articles#show', :constraints => {:year => /d{4}/, :month => /d{1,2}/, :day => /d{1,2}/ }
固定一切!