title: Accessing Route helpers in rails 3.2
body: <p>I'm migrating a rails 2.3 app to rails 3.2.
  I have an object used to manage the caching of a few stats I collect from different sources.
  As the collection process is quite long, It couldn't be done with the traditional fragment caching. 
  I had to fill the cache asynchronously.
  the AsynchCache object, get data from Google Analytics and stores the content of a partial in the cache.</p>
  
  <pre><code>include Rails.application.routes.url_helpers
  
  class AsynchCache 
  
    def self.get_popular_races_from_google_analytics(lang='en')
    # getting info form GA using Garb.
    end
  
  def self.set_popular_races(language=nil)
     av = ActionView::Base.new(Rails.configuration.paths['app/views'])
      language_list = Global.instance.languages_UI.map{|a| a[0]}
      for lang in language.nil? ? language_list : [language]
        output = av.render(
            :partial =&gt; "home/popular_races",
            :locals =&gt; {:lang =&gt; lang}
        )
        Rails.cache.delete("popular_races_#{lang}")
        Rails.cache.write("popular_races_#{lang}",output) 
      end
    end
  
   def self.get_popular_races(lang='en')
      Rails.cache.read("popular_races_#{lang}")
    end
  end
  </code></pre>
  
  <p>The partial I used for the display is as follows</p>
  
  
  <h3></h3>
      
      
          <ul>
              
              
                <li>"> tmp_race.name -%></li> 
              
              
          </ul>
      
  
  <p>When I want to display the content, I just have to use : </p>
  
  <pre><code>&lt;div id="popular_races"&gt; &lt;%# AsynchCache.get_popular_races(params[:locale])-%&gt; &lt;/div&gt;
  </code></pre>
  
  <p>It works fine when I first load the page, or in irb, but if I try to reload the page or set in development.rb config.cache_classes = true, I get an error : </p>
  
  <pre><code>stack level too deep
  Rails.root: /Users/macbook/Sites/marathons
  
  Application Trace | Framework Trace | Full Trace
  actionpack (3.2.1) lib/action_dispatch/middleware/reloader.rb:70
  </code></pre>
  
  <p>If I remove include Rails.application.routes.url_helpers, i don't get the error, but of course, I don't have acccess to the routes.</p>
  
  <p>Is there a new way to get the route methods from a model in rails 3.2?</p>