sferik / twitter-ruby

A Ruby interface to the Twitter API.
http://www.rubydoc.info/gems/twitter
MIT License
4.58k stars 1.31k forks source link

Error occured when I called client.update method. #914

Closed belion-freee closed 1 year ago

belion-freee commented 6 years ago

When I had executed this code.

require "twitter"

class Sns::Twitter::Base
  include ApplicationWorker

  def initialize
    @client = Twitter::REST::Client.new do |config|
      config.consumer_key        = env(:twitter_consumer_key)
      config.consumer_secret     = env(:twitter_consumer_secret)
      config.access_token        = env(:twitter_access_token)
      config.access_token_secret = env(:twitter_access_token_secret)
    end
  end
end

# this is other files
class Sns::Twitter::Tweet < Sns::Twitter::Base
  def tweet(content)
    client.update(content)
  end

  def random_tweet(category)
    maxims = Maxim.where(category: category)
    maxim = maxims.offset(rand(maxims.count)).first
    tweet format_tweet(maxim)
  end

  private

    def format_tweet(maxim)
      raise "no maxim" if maxim.blank?
      content = <<-BODY.strip_heredoc
        "#{maxim.remark}"
        - #{maxim.author}
      BODY
      content << maxim.url if maxim.url.present?
      content
    end
end

This Error occured. at called client.update(content).

private method `blank?' called for #<Twitter::REST::Client:0x00007fe8a0833868>

And, this Error occured since bundle update. Now, Using twitter 6.2.0. Before updating it worked fine. Do you know something about this Error?

belion-freee commented 6 years ago

Returning the gem version to 6.1.0, it works. I'll run for a while with this version.