In fact, you can add -as a separator and then use routing.
map.similar_product '/similar-to-*product', :controller => 'products', :action => 'similar'
then in ProductsController # similar
@product = Product.find_by_slug params[:product].join('-')
Although refactoring seems more enjoyable, since with this approach you need to specially process all the slugs that may contain hyphens.
source
share