Created
May 31, 2012 04:10
-
-
Save fj/2840961 to your computer and use it in GitHub Desktop.
DRYer way to do this route-drawing?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyApp::Application.routes.draw do | |
resources :fruits | |
resources :vegetables | |
resources :sandwiches | |
resources :desserts | |
resources :meats | |
resources :baskets do # DRYer way to do this? | |
resources :fruits # repeated route! :( | |
resources :vegetables # repeated route! :( | |
resources :sandwiches # repeated route! :( | |
resources :desserts # repeated route! :( | |
resources :meats # repeated route! :( | |
end | |
resources :refrigerators do | |
# ... repeats again | |
end | |
resources :freezers do | |
# ... repeats again | |
end | |
end |
ahcarpenter
commented
May 31, 2012
@cgriego That's a good point. Yes, the fruit resource is always the same.
But the information we might want to render in each view is different (e.g. "you're looking in refrigerator #234, which contains fruit #42" would only be shown on /refrigerators/234/fruits/42
, and not, say, /baskets/456/fruits/42
or /fruits/42
).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment