scope would be very effective for this. Replace what you placed above on your .rb routes with:
scope 'site/:site_pin' do resources :products end
Now run rake:routes and you will see the following output:
products GET /site/:site_pin/products(.:format) {:controller=>"products", :action=>"index"} POST /site/:site_pin/products(.:format) {:controller=>"products", :action=>"create"} new_product GET /site/:site_pin/products/new(.:format) {:controller=>"products", :action=>"new"} edit_product GET /site/:site_pin/products/:id/edit(.:format) {:controller=>"products", :action=>"edit"} product GET /site/:site_pin/products/:id(.:format) {:controller=>"products", :action=>"show"} PUT /site/:site_pin/products/:id(.:format) {:controller=>"products", :action=>"update"} DELETE /site/:site_pin/products/:id(.:format) {:controller=>"products", :action=>"destroy"}
:site_pin will be available as params[:site_pin] .
Naturally, you can add other resources and routes to the block of visibility; all of which will be prefixed with site/:site_pin .
source share