DocumentsController#common_query can handle multiple different request styles.
i.e. all docs in batch 4 or all docs tagged ‘happy’
I want a single route to make em pretty, so:
/documents/common_query?batch=4
/documents/common_query?tag=happy
become:
/documents/batch/4
/documents/tag/happy
So the end result is that #common_query is called but part of the url was used as the param name and part as it’s value.
As a single route:
Then
params[:type]will either be'batch'or'tag', andparams[:id]either'4'or'happy'. You will have to make sure that other actions for theDocumentsControllercome before this in the routes because this will match any url that looks like'documents/*/*'.But why does it have to be a single route? You could use two routes like this:
which will have the same effect, but is more specific, so you wouldn’t have to worry about the priority order of the routes.