的routes.rbRails 5.1:Globbing不起作用?
resources :posts
get '/posts/*missing', to: 'posts#missing'
/职位/ 1重定向到posts#show
,但/职位/航空自卫队不重定向到posts#missing
通配符不在这里工作了。为什么? 我正在使用Rails 5.1,在5.0上看到一个教程,使用完全相同的配置,并且globbing捕获了无效的ID。
我知道我可以使用rescue_from
,但我想通过routes.rb来做到这一点,我该怎么做?
您是否缺少路线中的单引号或其拼写错误? – Pavan
向我们展示该教程。 –