newUserNameHere
newUserNameHere

Reputation: 18011

How to change default Product Route in Spree?

Any ideas on what route it would take to change this URL:

http://domain.com/products/item1

To show and link to like this:

http://domain.com/item1/products

Current routes look like this:

root_path            GET                         /                               spree/home#index
products_path        GET                         /products(.:format)             spree/products#index
                     POST                        /products(.:format)             spree/products#create
new_product_path     GET                         /products/new(.:format)         spree/products#new
edit_product_path    GET                         /products/:id/edit(.:format)    spree/products#edit
product_path         GET                         /products/:id(.:format)         spree/products#show
                     PATCH                       /products/:id(.:format)         spree/products#update
                     PUT                         /products/:id(.:format)         spree/products#update
                     DELETE                      /products/:id(.:format)         spree/products#destroy

Upvotes: 1

Views: 1851

Answers (1)

Maksim Gladkov
Maksim Gladkov

Reputation: 3079

You would need to prepend the route:

get '/:id/products/' => 'spree/products#show', as: :product

to your config/routes.rb file.

Upvotes: 2

Related Questions