rails / journey

A router for rails
221 stars 57 forks source link

Find routes based on request class methods #11

Closed spohlenz closed 12 years ago

spohlenz commented 12 years ago

The old Rails router had a useful feature -- passing a request class to the RouteSet initializer -- which allowed me to override the path_info method in a custom request class to dispatch to a secondary router contained within a controller. This lets me to do subpath routing in my CMS without overriding env['PATH_INFO'] (which causes various issues with other helper methods as the PATH_INFO variable is no longer accurate).

Whilst Journey includes the custom request class feature, overriding the request methods is not currently possible as Router#find_routes method accesses the env hash directly rather than via methods on the Request object (even though it is available).

This patch fixes #find_routes to always access the request/env variables through the request class.

tenderlove commented 12 years ago

Hey, after merging this pull request, the actionpack tests in rails are failing. I'm going to revert this for now so the build is green again, but would you please investigate? Thanks!

spohlenz commented 12 years ago

@tenderlove This should now apply cleanly with the ActionPack tests all passing. Thanks.