Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7776747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:57:28+00:00 2026-06-01T17:57:28+00:00

here is what I am trying to do: Find if anyone has tweeted about

  • 0

here is what I am trying to do: Find if anyone has tweeted about a specific course offered. If someone has indeed tweeted about it, I’d like to save that tweet to my Tweet Model and then display that tweet in the corresponding course page.

The scripts works locally by running rails runner get_tweets.rb but on Heroku it seems that the script gets executed but doesn’t write to the database. In heroku I am running heroku run rails runner get_tweets.rb (using the Cedar stack).

def get_course_tweets
  @courses = Course.all
  @courses.each do |course|
    url = course.url
    tweets = Twitter.search(url, {:rpp => 100, :recent => true, :show_user => true})
    tweets.each do |tweet_info|
      unless Tweet.find_by_tweet_id(tweet_info.id).present?
        tweet = Tweet.new
        tweet.course_id = course.id
        tweet.tweet_id = tweet_info.id
        tweet.tweet_text = tweet_info.text
        tweet.from_user = tweet_info.from_user
        begin
          tweet.save!
        rescue => error
          puts error
        end
      end
    end
  end
end

Edit:

The current error I get from rescue is the following:

PG::Error: ERROR:  value "186306985577299969" is out of range for type integer : INSERT INTO "tweets" ("book_id", "course_id", "created_at", "from_user", "tutorial_id",     "tweet_already_exists", "tweet_id", "tweet_posted_to_reviews", "tweet_text", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING "id"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:57:30+00:00Added an answer on June 1, 2026 at 5:57 pm

    As can be seen from your error

    value “186306985577299969” is out of range for type integer

    you need to use a different datatype (for tweet_id, I believe), presumably a BIGINT, which ranges from -9223372036854775808 to 9223372036854775807.

    To do so in Rails you can pass :limit => 8 in your up migration:

    change_column :tweets, :tweet_id, :integer, :limit => 8
    

    Note that you should always do some sort of logging or reporting when you rescue, or else bugs like this become very difficult to track down because they silently get bypassed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am asking this here in the hope that someone has maybe come across
I am trying to find if there is a system color used here, so
I'm trying to find if scanResult is the currently connected wifi network. here is
I'm trying to find the value of a particular model's attribute in rails. Here's
I'm trying to find UIElement from coordinate in my Silverlight for WP7 application. Here
Java newbie here, I am trying to find the output of the following chunk
The TextWrapping feature in Silverlight is described here . However, I'm trying to find
Perhaps I'm asking for something impossible, but here we go: I'm trying to find
I was trying in Ruby on Rails how to find a prime number. Here
I can't seem to find an example of what I'm trying to do here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.