【发布时间】:2014-01-01 17:46:55
【问题描述】:
我有一个resources :posts。如何自定义它的以下路径以及使用正常资源路径名称调用它的能力:
URL Controller action Helper function
'q' 'posts#index' posts_path
'q/(:id)' 'posts#show' post_path(:id)
'ask' 'posts#new' new_post_path
'q' 'posts#create' posts_path
这是我尝试过的,但没有达到上述预期结果...
get 'q' => 'posts#index', as: :posts
get 'q/(:id)' => "posts#show", as: :post
get 'ask' => 'posts#new'
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-4 routes custom-routes