Created
October 24, 2012 17:55
-
-
Save codeodor/3947693 to your computer and use it in GitHub Desktop.
How do I keep all of these routes, but also make them available under a scope?
This file contains hidden or 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
# I have read http://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Resources.html#method-i-resources | |
# and remain clueless. | |
MyApp::Application.routes.draw do | |
resources :blogs do | |
resources :comments | |
end | |
# then imagine tons of routing below this | |
end | |
# So above, we can see we have routes with paths: | |
# /blogs | |
# /blogs/comments | |
# However, I want to create snapshots of the database periodically and make them | |
# available via: | |
# | |
# /snapshots/:snapshot_id/blogs | |
# /snapshots/:snapshot_id/blogs/comments | |
# The URLs above should go to the same controllers/actions as my original | |
# routes file defines. | |
# | |
# Also, the original /blogs and /blogs/comments should be available without the snapshot stuff. | |
# | |
# My idea here is that application_controller.rb will figure out when a | |
# snapshot is being requested, and switch the DB accordingly. | |
# So, I know I'm dense. How do I do that? Thanks! |
Ugh, forgot to preview. Here we go again:
So basically, imagine it's a long set of complex routes. I don't want to copy all of the routes into this new scope and maintain 2 copies. I want to just say "if you see a request for /snapshots/:snapshot_id/[some other route in the system]
then please stick :snapshot_id into the params
and go to [some other route in the system]
"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So basically, imagine it's a long set of complex routes. I don't want to copy all of the routes into this new scope and maintain 2 copies. I want to just say "if you see a request for /snapshots/:snapshot_id/ then please stick :snapshot_id into the
params
and go to "