Reputation: 444
I have an old wordpress woocommerce site that I rebuilt in rails.
Obviously it has a Product model and Products controller with routes.
The site is ready to launch.
My only problem is the old links go
www.mydomain.com/product/product-name
how do I either redirect or change my
www.mydomain.com/products/product-name
my routes file looks like so
resources :products do
resource :like, only: [:create,:destroy], module: :products
resource :collect, only: [:create,:destroy], module: :products do
put :sort, on: :collection
end
member do
get :toggle_status
end
end
Upvotes: 0
Views: 52
Reputation: 2290
http://guides.rubyonrails.org/routing.html#redirection
get '/product/:name', to: redirect('/products/%{name}')
Upvotes: 0
Reputation: 6253
you may check rails routing guide check section 4.7 Translated Paths
for your case above the translated route
resources :products, path: 'product'
Upvotes: 1