I have a Rails API using rails 5.2.1 and I'm developing a Web Scraping API that extracts web data using the Mechanize Gem.
What I'm going to do is, I'm going to pass all of this web scraping data data to React.js but first I need to get this data on my database which I'm having hard time how to figure this out.
So when I extract my data and I receive it all in a JSON file (called data.json), which I'm stunned I got until here haha.
{
"Brazil":[
{"Jungle Plants":[bla bla bla ]},
{"Desert Plants":[ bla bla bla ]}],
"Egypt":[
{"Jungle Plants":[bla bla bla ]},
{"Desert Plants":[ bla bla bla ]}]
and so on...
}
So the next thing I need to do is separate my JSON data into my database which I already have a migration setup like this:
class CreatePlants < ActiveRecord::Migration[5.2]
def change
create_table :plants do |t|
t.string :country_name
t.string :plant_categories
t.timestamps
end
end
end
So up in the table what I want to is, I want that the country name like 'Brazil' or 'Egypt' or whatever country name is goes to the country_name column and so for the plant_categories.
My question is, how can I organize/separate my data.json file in to my database? I will appreciate so much your help! <3