rails 301通过路径选项重定向资源



我有这样的路线

resources :people, :path => "designers", :only => [:index, :show] do
  member do
    post 'add_favorite_designer'
    post 'remove_favorite_designer'
  end
end

我可以使用example.com/peopleexample.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]}" }

最新更新