module Twitter module Rails class << self def load_configuration(twitter_yaml_file) twitter_yaml_file = ::Rails.root + 'config' + 'twitter.yml' if File.exists?(twitter_yaml_file) twitter_config = YAML.load(File.read(twitter_yaml_file))[RAILS_ENV] ENV['TWITTER_CONSUMER_TOKEN'] = twitter_config['token'] ENV['TWITTER_CONSUMER_SECRET'] = twitter_config['secret'] end end end end end class ActionController::Base class << self def inherited_with_twitter(subclass) inherited_without_twitter(subclass) if subclass.to_s == "ApplicationController" subclass.class_eval do include Twitter::Rails::Controller helper Twitter::Rails::Helpers end end end alias_method_chain :inherited, :twitter end end twitter_config = Rails.root + 'config' + 'twitter.yml' Twitter::Rails.load_configuration(twitter_config)