ruby - Rails Single Resource as Nested Resource of Two Other Resources -


i have business, catalog , product resource.

a business has catalog , number of products.

a catalog belong business.

a product may or may not under catalog.

the products table both has catalog_id , business_id.

how form route can allow product without catalog , product belonging catalog, i.e., these urls:

  • businesses/:business_id/catalogs/:catalog_id/products/:id
  • businesses/:business_id/products/:id

i have allowed latter using this:

resources :businesses     resources :catalogs      resources :products       resources :images       end   end 

how modify allow first url?

i know i'm missing simple, feel free close , refer duplicate if there one.

thanks lot!

well, there:

resources :businesses     resources :catalogs       resources :products         resources :images       end     end      resources :products       resources :images     end end 

the same way did businesses/products can businesses/catalogs/products, there no difference, nest resources.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -