I use bitly gem and would like to have access to the bitly API inside my helper methods (which invoke calls and mailers to create URLs).
I initiate an API connection in this method in my ApplicationController:
(is there any more suitable place for this BTW?)
class ApplicationController < 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
By default, I do not have access to @bitly in my helpers. Can you suggest a way to do this?
The only related thread I found did not help: Rails 3 and controller instance variables inside the helper
Thanks.
ruby-on-rails helpers
stupakov
source share