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 8764279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:59:35+00:00 2026-06-13T15:59:35+00:00

I have an app on heroku which scrapes pricing data off a website and

  • 0

I have an app on heroku which scrapes pricing data off a website and saves it periodically. For some reason whenever I run the rake task locally, it acts as expected, but when I run the task on heroku it adds extra output and is saving the object twice for some reason.

Output when I run locally

a,12.80 saved at 2012-10-26 03:36:17 UTC.
b,38.03 saved at 2012-10-26 03:36:24 UTC.
c,22.38 saved at 2012-10-26 03:36:31 UTC.

Output when I run on heroku

a,12.80 saved at 2012-10-26 03:36:17 UTC.
b,38.03 saved at 2012-10-26 03:36:24 UTC.
c,22.38 saved at 2012-10-26 03:36:31 UTC.
#<Stock:0x000000047bb5e8>,12.80 saved at 2012-10-26 03:36:45 UTC.
#<Stock:0x000000047baaf8>,38.03 saved at 2012-10-26 03:36:48 UTC.
#<Stock:0x000000047b00a8>,22.38 saved at 2012-10-26 03:36:52 UTC.

Code

require 'open-uri'
require 'date'

namespace :data do 
  desc "import current blah stock price data to database"
  task :importblah => :environment do

  #pass in a stock and price and save it to the database
  def save_stock(stock, price)
    #store stock data in database
    p = stock.prices.build
    p.price = price
    p.datetime = Time.now.utc.to_datetime

    if p.save
      puts "#{stock.symbol},#{price} saved at #{p.datetime.to_s}."
    else
      puts "#{stock.symbol} didn't save."
    end
  end

  actives = Parent.where("test1 = ?", true)

  actives.each do |m|

    stocks = m.stocks.where('test2 = ?', false)
    stocks.each do |stock|
      if stock.title.start_with?('blah')
        #grab stock price data from blah.com
        url = "blah"+stock.symbol
        doc = Nokogiri::HTML(open(url))
        price = doc.at_css(".value").text[/\d+\.\d+/]
        save_stock(stock, price)
      end


    end
  end


  end
end

I have an almost identical rake task for a different site and it is not saving the pricing data twice. I am using Amazon RDS db if that affects anything.

  • 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-13T15:59:38+00:00Added an answer on June 13, 2026 at 3:59 pm

    Turns out it was a problem with git tracking where I deleted files locally but forgot to

    git rm oldraketask.rake
    

    which happened to contain a rake task with the same name as the one I was running so heroku was running both rake tasks consecutively, first the new one and then the one from the old file still on heroku’s servers.

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

Sidebar

Related Questions

I have a simple sinatra app on Heroku which fetches some json data and
I have an app hosted @ Heroku. The app depends on some feeds which
I have an app hosted on Heroku and this app need to run some
I currently have an app deployed on Heroku which runs on two web dynos
I am creating a Node.js app on Heroku and have run into an issue.
I have created an App on Heroku which works perfectly in a Web Browser.
The Problem I have a Rails 3.1 app on Heroku which will soon require
I have a rails app running on Heroku. I am using paperclip for some
I have an app running on heroku, which I versioning on github too. But
we need to build a heroku app which stores data in a DB table.

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.