title: link_to url helper not working in render_to_string for Rails 4
body: <p>I am trying to get link_to to work when rendering a view outside of a controller. I've tried a couple different solutions found on the internet. You can see one attempt commented out.        </p>
  
  <p>It keeps resulting in: undefined method `host' for nil:NilClass</p>
  
  <pre><code>    ac = ApplicationController.new
      ac.class.include Rails.application.routes.url_helpers
  
      #context = Rails.configuration.paths['app/views']
      #view = ActionView::Base.new(context)
      #view.class.include Rails.application.routes.url_helpers
      #view.render :layout =&gt; 'layouts/pdf.html.haml', :template =&gt; 'reports/show.pdf.haml', locals: {alerts:@alerts}
  
      ac.render_to_string(:layout =&gt; 'layouts/pdf.html.haml', :template =&gt; 'reports/show.pdf.haml', locals: {alerts:@alerts})
  </code></pre>
  
  <p>I also tried over riding the class. None of the ActionView::Base stuff seems to work.</p>
  
  <pre><code>class ViewRenderer &lt; ActionView::Base
    include Rails.application.routes.url_helpers
    include ApplicationHelper
  
    def default_url_options
       {host: Rails.application.routes.default_url_options[:host]}
    end
  end
  </code></pre>