I am trying to get Twitter gem version 5.1.1 to work in my application, but I'm having configuration problems, I am running rails 4 and Ruby 2.0.0. In my Gemfile, I have a "gem" twitter "and it installed it through a binder. According to the documentation, I created an initialization file in config / initializers / twitter_credentials.rb. This file looks like this (although I have a key and secrets filled in my Twitter info):
require 'twitter'
client = Twitter::REST::Client.new do |config|
config.consumer_key = "YOUR_CONSUMER_KEY"
config.consumer_secret = "YOUR_CONSUMER_SECRET"
config.access_token = "YOUR_ACCESS_TOKEN"
config.access_token_secret = "YOUR_ACCESS_SECRET"
end
When I try to use the client in the rails console, this is the error message I get:
2.0.0p353 :001 > client.update("I'm tweeting with @gem!")
NameError: undefined local variable or method `client' for main:Object
from (irb):1
from /Users/user_name/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/commands/console.rb:90:in `start'
from /Users/user_name/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/commands/console.rb:9:in `start'
from /Users/user_name/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/commands.rb:62:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
Any idea what the problem is?
source
share