我期待的模式state/city
路徑匹配,除非狀態變量等於「權威性」Rails 3的路由約束和正則表達式
match '/:state/:city' => 'cities#index', :as => :state_cities, :constraints => {:state => /(?!auth)/ }
例如,mydomain.com/fl/miami
好。 mydomain.com/auth/twitter
不好。
我使用的是omniauth,它需要您去/auth/twitter
進行身份驗證,但是當我輸入rake routes
時無處可查。
在'matches?'中使用'!request.fullpath.start_with?('/ auth /')'可能會更好一些,不妨保留整個'/ auth'命名空間。 – 2011-05-09 02:15:31