I have Products page that use the ugly param to handle sorting.
products_path(sort: "asc")
# resulting in
/products?sort=asc
I'm trying to make the URL looks like /products/asc. So I'm playing with the routes:
# routes.rb
get "/products/:sort", to: "products#index", as: "products_path"
Now, going to /products/asc works perfectly fine.
But products_path(sort: "asc") still generate /products?sort=asc.
Is there a way to make it generate the pretty URL?
Thanks
[EDIT and ANSWER]
I typo the as:. Should be:
# routes.rb
get "/products/:sort", to: "products#index", as: "products"