SujitS
SujitS

Reputation: 11423

friendly-id custom url in rails

I have successfully integrated friendly-id and is working fine. My product can be viewed from (localhost:3000/product/test-product) url. What I want is to have a short url like (localhost:3000/test-product) for my product.

How can I achieve this in friendly-id or in rails.

Thank you in advance.

Upvotes: 1

Views: 229

Answers (1)

SSR
SSR

Reputation: 6438

You need to create your custom route to achieve this :

In routes.rb

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

Call like

product_path(product.slug)

Upvotes: 1

Related Questions