Question: I have a json file with a lot of movies in it. I want to create a model 'Movie' and fill it with all movies from that json file. How do i do it? I know that I can parse json file into a hash but that's not the thing I am looking for.

Answer: 
The correct term you're looking for is "seeding"!

You're going to need a database however, and a migration to create the database along with the associated `movies` table. (There are plenty of guides on how to do this, along with the official [documentation](https://guides.rubyonrails.org/active_record_migrations.html)).

After that's done, you'll need to "seed" your database with the data in your json file.

In the `seeds.rb` file, assuming that the JSON file is an array of `Movies` in JSON form, you should be able to loop over every `Movie` JSON object and insert it into your database.
For my case, I need to seed around **200 hundred datas** for production from a JSON file, so I tried to insert data from the json files in a database.

**SO** at first I created a database in rails project

```
rails generate migration create_movies title:string duration_in_minutes:integer
# or whatever fields you have

# edit the file to add other fields/ensure it has what you want.
rake db:migrate

```

**Now its time to seed datas!**
Suppose your `movies.json` file has:

```
[
 {"id":"1", "name":"Titanic", "time":"120"},
 {"id":"2", "name":"Ruby tutorials", "time":"120"},,
 {"id":"3", "name":"Something spetial", "time":"500"}
 {"id":"4", "name":"2HAAS", "time":"320"}
]

```

NOW, like this 4 datas, think your JSON file has 400+ datas to input which is a nightmare to write in seed files manually.
You need to add **JSON** gem to work. Run

```
bundle add json

```

to work with JSON file.

In `db/seed.rb` file, add these lines to add those 400+ infos in your DATABASE:

```
infos_from_json = File.read(your/JSON/file/path/movies.json)
JSON.parse(infos_from_json).each do |t|
  Movie.create!(title: t['name'], duration_in_minutes: 
t['time'])
end

```

**Here:**

* `infos_from_json` variable fixing the JSON file from file directory
* `JSON.parse` is calling the JSON datas then the variable is declared to indicate where the file is located and `each do` loop is dividing each data and `|t|` will be used to add part `JSON.parse(infos_from_json).` in every call.
* `Movie.create!(title: t['title'], duration_in_minutes: t['time'])` is adding the data in database

This is how we can add datas in our database from a JSON file easily.

For more info about seeding data in database checkout the [documentation](https://guides.rubyonrails.org/active_record_migrations.html#migrations-and-seed-data)

**THANKS**

Edit: This operation requires **JSON gem** just type `bundle add json`