Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RoR - uninitialized constant Twitter::Client

twitter_helper.rb

module TwitterHelper

  require 'rubygems'
  require 'twitter'
  require 'net/http'
  require 'uri'


  def get_tweets (twitter_user)
    begin
        @tweets = Array.new
        @twitter = Twitter::Client.new

        Twitter.user_timeline(twitter_user) do |tweet|
            @tweets.push(tweet)
        end
        @tweets
    rescue Exception => e
      puts e
      _("Errors: #{e.to_s}
        ")
    end
  end

end

My gemfile includes

gem 'twitter'

And I've done

bundle install

But every time I call

tweets = get_tweets

From my view I get the exception (uninitialized constant Twitter::Client). What am I missing?

like image 510
David Ryder Avatar asked Nov 29 '25 22:11

David Ryder


1 Answers

I hate answering my own questions, but here goes.

Check the version number. Significant changes were made between the twitter gem <1.0 and >=1.0. You should specify

gem 'twitter', '>= 1.0'

And then

bundle install

And resolve any dependency conflicts (if you get any).

like image 197
David Ryder Avatar answered Dec 01 '25 12:12

David Ryder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!