我有这样的路线
resources :people, :path => "designers", :only => [:index, :show] do
member do
post 'add_favorite_designer'
post 'remove_favorite_designer'
end
end
我可以使用example.com/people
和example.com/designers
。但是,我想用301代码将example.com/people
重定向到example.com/designers
,并且我想用path选项为所有资源实现它。有什么方法可以使它自动化吗?
路径/people
应该不再可用,因为在使用:path
参数时,它已被/designers
替换。
如果要将所有请求从/people
重定向到/designers
,请使用
match '/people/*action', to: redirect {|p, req| "/designers/#{p[:action]}" }