Skip to content

Instantly share code, notes, and snippets.

@johana-star
Created November 16, 2011 23:58
Show Gist options
  • Save johana-star/1371923 to your computer and use it in GitHub Desktop.
Save johana-star/1371923 to your computer and use it in GitHub Desktop.
Fixed: my attempt at using a yml file to configure the twitter gem.
:twitter:
:consumer_key: Buncharandomletterssee
:consumer_secret: BuncharandomlettersautogeneratedformebyTwit
:oauth_token: Thisoneh-asadashinthemiddleofittomakeitseemmoreimp
:oauth_token_secret: IgetanilrelatederrorwhenItrytousethiscruftI
require "twitter"
require "yaml"
# The fix is in, initially I was looking for an array called twitter inside an array called twitter, which returned nil. Doh!
# See also: Configuring YAML: http://blog.innovativethought.net/2009/01/02/making-configuration-files-with-yaml-revised/
# And setting up the Twitter gem: https://github.com/jnunemaker/twitter/blob/master/README.md
Twitter.configure do |c|
config = YAML.load(File.read("config.yml"))[:twitter]
c.consumer_key = config[:consumer_key]
c.consumer_secret = config[:consumer_secret]
c.oauth_token = config[:oauth_token]
c.oauth_token_secret = config[:oauth_token_secret]
end
@briantrice
Copy link

s/APP_CONFIG[:twitter]/APP_CONFIG/g

@johana-star
Copy link
Author

@briantrice Initially I was confused by your comment, then I realized you were indicating replace with vi syntax. Thx for the helpful tip!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment