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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:00:21+00:00 2026-06-18T21:00:21+00:00

I need to make a XML request every minute, and then store the data

  • 0

I need to make a XML request every minute, and then store the data in a Medida object. Every Meter object has many Medidas (measurements).

class Meter < ActiveRecord::Base

  has_one :user_type
  has_one :user
  has_many :medidas
  attr_accessible :user_type_id, :user_id, :address, :etc


  def read_data
      u = User.find(self.user_id)
      Medida.get_data(self.address,u.user_key, self.id) 
  end


  class << self
    def all_read_data
      meters = Meter.all
      meters.each do |meter|
        meter.read_data
      end  
    end
  end
end

Medidas.rb looks like

class Medida < ActiveRecord::Base
  belongs_to :meter
  attr_accessible  :some_attr

  class << self
    def get_data(address,user_key, meter_id)
      url="some_url_with#{variables}.xml?#{a_key}"

      response = HTTParty.get(url)

      hash = Hash.from_xml(response.to_s)
      hash = Medida.some_funct(hash)
      data = hash["ekmMeterReads"]["meter"]["read"]

      #Save hash to bd
    end
    #def some_funct
  end
end

I’m using Whenever for this. And this is how my schedule.rb looks like

set :output, "#{path}/log/cron.log"

every 1.minutes do
    runner "Meter.all_read_data, :environment => 'development'
end

The problem is that actually only one Meter gets its data every minute and all the others are left without it. This is the content for my cron.log (it has an issue, but I have failed to find useful information about it.)

What am I missing? Thanks for any insight.

  • 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-18T21:00:23+00:00Added an answer on June 18, 2026 at 9:00 pm

    I got it. The url I’d been given to make the call was the wrong one.
    Everything working smoothly now.

    If you depend on someone else’s information (like codes, keys, urls) be sure to be extra inquisitive about that information. Is better to lose some minutes doing that, than a day trying to do something which you are not supposed to do.

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

Sidebar

Related Questions

I have to make a HTTPS Post with some XML data, but I need
I need to make a POST request via cURL from the command line. Data
I need make some action (dump statistical data) before the Dart program ends. The
I need make all of my posts update. I use bulk upload for store,
I need to make a request to an API, using REST (POST method) in
I need to make an AJAX request to some script from the onSave event
I need to send a HTTP request (and get XML response) from Flash that
I'm trying to make a POST request using HTTParty, in which I need the
I need to make the above equation comes true! I have an XML file
I have the following kind of data returned to me in xml format (many

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.