2013-12-16 49 views
1

我有這樣軌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。但是我想example.com/people301碼重定向到example.com/designers,我想實現它適用於所有具有路徑選項的資源。是否有任何方法將其自動化?

回答

1

路徑/people不應再可用,因爲當您使用:path參數時,它已被替換爲/designers

如果你想從/people所有請求重定向到/designers,使用

match '/people/*action', to: redirect {|p, req| "/designers/#{p[:action]}" }