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.
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.
What you need is FriendlyId which is covered in this RailsCasts episode.
You may want the following route:
get ':sport_id', :to => 'products#show'
class ProductsController < ApplicationController
def show
render text: "sport is #{params['sport_id']}"
end
end
match 'volleyball' => 'spree/products#index', :defaults => { :sports => '2' }
– Daniel Broughan Sep 12 '13 at 15:40