I feel this is should be easy but I’m stuck. What’s the best way to map a route and have it point to specific url?
User types/click http://acne.com/category-name and it will get http://acne.com/?category[]=1
I don’t want to redirect to ?category[]=1 though. I want to make it SEO friendly.
2
Answers
Use the friendly_id gem.
Here is an example o how it could work:
If I understood your question correctly, you want to show the category when user types in acne.com/category-name.
Add this in your config/routes.rb:
get ‘/:category-name’, to: ‘category#show’
This will route the request to your categoryController’s show method with the user-typed category name in the “category-name” parameter. You can handle what is displayed there (use params[:category-name] to find out the category name the user has typed in)
Sorry for the lack of code tags, I’m on mobile.