Skip to content

Instantly share code, notes, and snippets.

@nu7hatch
Created September 8, 2010 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nu7hatch/570788 to your computer and use it in GitHub Desktop.
Save nu7hatch/570788 to your computer and use it in GitHub Desktop.
MyApp.controllers :product do
parent :shop, :optional => true
parent :category, :optional => true
get :show, :with => :id do
# generated url: "/(shop/#{params[:shop_id]}/)(category/#{params[:category_id]}/)product/show/#{params[:id]}"
# url_for(:product, :show, :id => 10) => "/product/show/10"
# url_for(:product, :show, :shop_id => 5, :id => 10) => "/shop/5/product/show/10"
# url_for(:product, :show, :shop_id => 5, :category_id => 1, :id => 10) => "/shop/5/category/1/product/show/10"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment