pboling/subdomain-fu — pull request #1 by joslynesser (2011-10-12 17:41:54+00:00)
Title: Fix with including Rails.application.routes.url_helpers and building relative paths

Fixing url_rewriter when there is no host available (example: including url_helpers in a model where a @request object is not available)

When including the url helpers in a model and trying to build a relative path, the following error occurs:

ruby-1.9.2-p290 :005 > model.root_path
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.count
from /Users/joslynesser/.rvm/gems/ruby-1.9.2-p290/bundler/gems/subdomain-fu-a0ed77629a1a/lib/subdomain_fu/subdomain_fu.rb:134:in 'needs_rewrite?'
from /Users/joslynesser/.rvm/gems/ruby-1.9.2-p290/bundler/gems/subdomain-fu-a0ed77629a1a/lib/subdomain_fu/url_rewriter.rb:7:in 'url_for_with_subdomains'
from /Users/joslynesser/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.9/lib/action_dispatch/routing/url_for.rb:131:in 'url_for'