我有unless
语句的以下模型,因为我不想保存like和转发等于0的推文。但是,当我使用Twitter gem运行我的脚本时,我保存错误鸣叫。
class Twit < ApplicationRecord
def self.get_tweets user
all_tweets = CLIENT.user_timeline(user, count: "20", exclude_replies: true, include_rts: false)
all_tweets.each do |tweet|
unless (tweet.favorite_count == 0 && tweet.retweet_count == 0)
Twit.find_or_create_by(link: "#{tweet.uri}") do |twit|
twit.content = tweet.text
twit.like = tweet.favorite_count
twit.retweet = tweet.retweet_count
twit.first_date = tweet.created_at
twit.engagement == (tweet.favorite_count + tweet.retweet_count)
end
end
end
end
任何提示?谢谢。