Skip to content

Instantly share code, notes, and snippets.

@Bill
Created September 22, 2008 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bill/12001 to your computer and use it in GitHub Desktop.
Save Bill/12001 to your computer and use it in GitHub Desktop.
# 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