我已经有了一条为用户显示页面匹配/username的路径。但是,当我添加另一个操作时,例如:追随者和如下:
resources :users, :only => [:show] do
get :following, :followers
end我得到的是URL /users/username/following而不是/username/following。
我如何使所有的/users/username网址被匹配为/username/etc。?
这是我的/username路线:
match '/:id' => 'users#show', :constraints => { :id => /[a-zA-Z0-9\-_]*/ }, :as => "user_profile"谢谢。
编辑:
我已经修正了这个通过添加
match '/:id/following' => 'users#show/following', :as => "user_following"
match '/:id/followed' => 'users#show/following', :as => "user_followers",但我不确定这是否是最好的解决方案。我真正想要的是一个默认的路由,它可以将所有的/:id/:action /users**.**匹配到省略/users**.**的适当操作。
发布于 2011-01-10 15:10:51
我已经修正了这个通过添加
match '/:id/following' => 'users#show/following', :as => "user_following"
match '/:id/followed' => 'users#show/following', :as => "user_followers"但我不确定这是不是最好的解决办法。我真正想要的是将所有/:id/:操作与省略/users的适当操作匹配的默认路由。
发布于 2011-02-01 04:01:45
靠近底部
match ':id/:action', :controller => :usershttps://stackoverflow.com/questions/4638770
复制相似问题