0

I'm trying to automate my database population with sample objects, so I use rake tasks. I would like to use some data from other website pages. I created txt file with url list from where that information supposed to be read and ran into problem: I don't know how to make requests outside from rake task. I need to get response, extract some selectord as RSPEC allows to do. Thank you, guys!

Roaring Stones
  • 1,054
  • 7
  • 22

1 Answers1

0

For custom rake tasks, you can always create your own plugin. Refer rails guide - plugins section. In the plugin, you can use get method to get the data from an external URL. Refer ActionDispatch::Integration::RequestHelpers methods for the details. You can add your own extraction logic and seed the database.

Salil
  • 9,534
  • 9
  • 42
  • 56