Created
November 16, 2011 23:58
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:twitter: | |
:consumer_key: Buncharandomletterssee | |
:consumer_secret: BuncharandomlettersautogeneratedformebyTwit | |
:oauth_token: Thisoneh-asadashinthemiddleofittomakeitseemmoreimp | |
:oauth_token_secret: IgetanilrelatederrorwhenItrytousethiscruftI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 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
s/APP_CONFIG[:twitter]/APP_CONFIG/g