我期待的模式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