title: Rails: controller method or instance variable inside a helper
body: <p>I'm using the bitly gem and would like to have access to the bitly API inside my helper methods (which get called by views and mailers to generate URLs).</p>
  
  <p>I initiate an API connection in this method in my ApplicationController:</p>
  
  <p>(is there a more appropriate place to do this BTW?)</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    before_filter :bitly_connect
  
    def bitly_connect
      Bitly.use_api_version_3
      @bitly ||= Bitly.new(APP_CONFIG['bitly_username'], APP_CONFIG['bitly_api_key'] )
    end
  end
  </code></pre>
  
  <p>By default I don't have access to <code>@bitly</code> in my helpers.  Can you suggest a way to accomplish that?</p>
  
  <p>The only related thread I found wasn't helpful:
  <a href="https://stackoverflow.com/questions/5208689/rails-3-and-controller-instance-variables-inside-a-helper">Rails 3 and Controller Instance Variables Inside a Helper</a></p>
  
  <p>Thanks.</p>