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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:21:32+00:00 2026-06-05T10:21:32+00:00

Apologies for the probably noobie question: I have a rake task that is designed

  • 0

Apologies for the probably noobie question:

I have a rake task that is designed to take data from a site and save it as a RateData object.

rs.each do |market,url| 
  doc = Nokogiri::HTML(open(url))  
  doc.xpath("//table/tr").each do |item|  
    provider = "rs"
    market = market
    rate = item.xpath('td[1]').text.gsub!(/[^0-9\.]/, '')
    volume = item.xpath('td[2]').text.gsub(/[^k0-9\.]/, '')
    volume = volume.gsub(/\.(?=.k)/, '')
    volume = volume.gsub(/k/, '00')
    volume = volume.to_f
    rate = rate.to_f
    RateData.create(:provider => provider, :market => market, :rate => rate, :volume => volume, :bid_ask => 1)
  end
end

The RateData.create method is in the rate_data_controller and is accessible when I call it in the rails console. How can I make it available in this rake task?

Many thanks!

  • 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-05T10:21:34+00:00Added an answer on June 5, 2026 at 10:21 am

    you need to pass the environment into the task

    task :your_task, [] => :environment do
    

    or with args

    task :your_task, [:foo] => :environment do |task, args|
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have what is probably a really dumb grep in R question. Apologies, because
Apologies for asking what's probably a very obvious question, I've been banging my head
Apologies or asking what is probably a very straightforward question, but I'm new to
again, apologies for what is probably a straightforward question! Ok, so! my problem is
This question hasn't been asked yet. Some solutions probably have been proposed though to
Apologies for probably simple question, I've read the docs and still can't get this
This is probably a really easy question, so apologies for not being more challenging!
Apologies for what is probably a newbish question. I am writing some Powershell scripts
No idea how to go about this. Apologies if it's a stupid question (probably
Apologies if this is too ignorant a question or has been asked before. A

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.