Customizing Resources #24

jorr opened this Issue Nov 26, 2013 · 0 comments


None yet
1 participant

jorr commented Nov 26, 2013

A slightly exotic but I believe useful option, would be letting resources:

  • fetch parameters from the url match
  • dispatch to a custom controller (that does not correspond to the url)

The case these try to solve is pretty URLs for categories of a single resource.
Say in a shop website, having /chairs/:id, /tables/:id, /beds/:id all dispatch to a Product controller with a type parameter to distinguish between them.

I imagine something in the lines of:


which would be pretty easy to implement - just provide the first parameter instead of #{slug} and the second parameter instead of #{controller} in the routes generated by the constructor. The methods of the controller would then have params.type available as whatever was between the slashes.

there might be a better syntax to make these optional and whatnot..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment