I am trying to create a URL friendly link from a string. Instead of example.com/Jessica Alba, I want example.com/jessica-alba. How do I get the link_to tags to link me to the seo friendly permalink?
I also need to make sure that the show method only displays the seo friendly permalink in the address bar and only accepts the seo friendly permalink.
You can override the
to_parammethod in your model.So if you have a model called
Celebrity, which has anamecolumn you can go:Then: