Background Jobs
Hey there,
I'm using nested attributes to generate a bunch of records at once. I'm coding a tool that crawls IP and Website Informations.
The nested attributes are set up like this:
-Company
--has_many: IP-Areas
---has_many: IP-Subnets
----has_many: IP-Addresses
-----has_many: Sites
------has_many: Targets
Each one belongs_to the respective parent. But when it comes to IP-Addresses we're speaking of 1.000.000+ records. You only need to enter the Company name and everything works like a charm. IP-Areas is receiving a ID which identifies a lot of subnets, the subnets are getting iterated over and then I have the IP-Addresses. From there I'm generating a bunch of other records.
So my question:
The form in which you type in the company (and that basically triggers EVERYTHING else, which is pretty cool) takes ages to load because there is so much processing in the background.
I can't find a good tutorial how to actually move everything inside a background job. I'm really stuck there. Do you know a good approach on that or a good ressource that I can look up (not the RoR officials please..).
Thanks a lot,
Sascha
Hi Sascha,
Check out this tutorial: https://www.sitepoint.com/simple-background-jobs-with-sucker-punch/
That should get you going!
Gorails also did this tutorial:
https://gorails.com/episodes/background-workers-with-activejob-and-sidekiq?autoplay=1