在rails 5中更改URI模式

时间:2017-09-25 19:26:21

标签: ruby-on-rails ruby-on-rails-4

我在routes.rb

中有这个
get 'search#search', to: 'search#search', as: 'search'

如果我rails routes,则返回以下内容:

search GET    /search%23search(.:format)        search#search

我想将/search%23search更改为search/search

我该怎么做?

1 个答案:

答案 0 :(得分:2)

在rails中你写为:

get 'search/search', to: 'search#search', as: 'search'

这将导致:

search GET    /search/search(:format)        search#search