ruby-on-railsvariablesgetpretty-urls

Rails routing for pretty urls and get variables


Rails noob here

I have a url "/products?sports=2", which shows the products fine. But I want the url to be "/volleyball"

I currently have, which I know is completely worng:

match 'volleyball' => 'products?sports=2'

Any suggestions? Thanks.


Solution

  • What you need is FriendlyId which is covered in this RailsCasts episode.