Created
September 22, 2008 14:47
-
-
Save Bill/12001 to your computer and use it in GitHub Desktop.
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
# This is an attempt at an improved version of params_for or rspec rails. It is meant to | |
# support recognition of paths when the Rails environment has been extended via patches like these: | |
# http://weblog.jamisbuck.org/2006/10/26/monkey-patching-rails-extending-routes-2 | |
# http://svn.danwebb.net/external/rails/plugins/request_routing/trunk/README | |
# So instead of route :conditions having only :method, they may now have other data such as :domain | |
def recognize_path( path, options) | |
if options[:host].kind_of?( Array ) | |
result = options[:host].collect{ | h | route( path, options.merge( :host => h) ) } | |
else | |
begin | |
# This doesn't quite work since unfortunately, extract_request_environment hasn't been | |
# invoked yet! | |
result = ActionController::Routing::Routes.recognize_path( path, options) | |
rescue ActionController::RoutingError | |
end | |
end | |
result | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment