title: Rails3: rewrite url_for for subdomain support, how to extend action mailer to use such url_for
body: <p>I take code from <a href="http://railscasts.com/episodes/221-subdomains-in-rails-3" rel="nofollow">Subdomain RailsCast</a></p>
  
  <pre><code>module UrlHelper
    def with_subdomain(subdomain)
      subdomain = (subdomain || "")
      subdomain += "." unless subdomain.empty?
      [subdomain, request.domain, request.port_string].join
    end
  
    def url_for(options = nil)
      if options.kind_of?(Hash) &amp;&amp; options.has_key?(:subdomain)
        options[:host] = with_subdomain(options.delete(:subdomain))
      end
      super
    end
  end
  
  class ApplicationController &lt; ActionController::Base
    include UrlHelper
  end  
  </code></pre>
  
  <p>It is ok to use modified <code>url_for</code> in views of Controllers. But I have trouble with ActionMailer.</p>
  
  <p>I tried to use following:</p>
  
  <pre><code>class Notifier &lt; ActionMailer::Base
    include UrlHelper
  end
  </code></pre>
  
  <p>But ActionMailer views still use old unmodified url_for from ActionDispatch::Routing::RouteSet.</p>
  
  <p>What is the best practice to add new url_for</p>