Ruby: Is it a gem or is it a language?
Funny that you asked! Ruby is both a gem and a language! How is that possible you ask? Well, humans have decided to make it both. Certainly not at the same time though. Ruby, the language, was founded in 1995 by Yukihiro Matsumoto. The shiny ruby gem was founded in 2500 B.C. in Burma, South East Asia. This begs the question why Yukihiro Matsumoto named this shiny red gem as the name of the computer language he found? Well he wanted to name something that was named after an actual gem. Some example are ruby, diamond, sapphire, jade, etc. But he decided to name it ruby cause it was easier to type than the other gems.
Now, enough about this discussion, now to my experience with Ruby (the language) at Flatiron School. First off, the language was certainly different from Javascript, HTML, CSS, and React. Obviously, this was the first time I interacted with a ‘back-end’ language. This shift was certainly difficult at first and I needed lots of reading and Flatiron School labs to understand the gist of what it is. To put it simply, Ruby is a language that focuses on databases and the implementation of databases to ultimately be used by the ‘front-end’ languages such as Javascript, HTML, CSS, and React. A lot of what we were tested on included making migrations of tables, which was done in the terminal. A command such as bundle exec rake db:create_migration NAME=create_reviews would make a table called create_reviews. This would then need to be given column names which would be made in the code editor of choice (VSCode, Vim, etc). I used VSCode. For example, for this table, inside the section called ‘migrate’ the migration (which is a time stamp of when you ran bundle exec rake db:create_migration NAME=create_reviews) is shown as 20220603141926_create_reviews.rb.
You will know this has occurred when you see a new file named 20220603141926_create_reviews.rb created and looks like this:

In this file under def change, to complete making the table you must put:
create_table :reviews do |t|
t.integer :star_rating
t.integer :restaurant_id
t.integer :customer_id
end
Which looks like the image below:

All this code says is that we want to create a table named reviews and the columns we want is called star_rating, restaurant_id, and customer_id. Then when this is filled out above, run bundle exec rake db:migrate which you will know this migration worked when you look at the schema.rb file (in the db folder) and see this below:

What you see in the table below is what will be shown when we make a file inside the ‘db’ folder (which is also where schema.rb is located) called seeds.rb and add data to it. In order to fill out the seeds.rb properly, you need to put Review.create(star_rating: 3, restaurant_id: 2, customer_id: 2) for every row you want to create. In the image below, three reviews were created. The use of the columns we named and using correct data types is crucial. For example, using an integer is needed for all of these columns because the data type was specified previously in 20220603141926_create_reviews.rb. So if we put a string ‘3’ in the first review it would not work, we would have to put the integer 3. Also, the Review.destroy_all was done so that the data you make doesn’t get duplicated. To finally get what you see in the seeds.rb file into an actual table that is shown below the picture of seeds.rb, you have create some seeds, shown below, and then run bundle exec rake db:seed.

This table below will appear after running bundle exec rake db:seed in your console.

Overall, this phase at Flatiron School, phase 3, was certainly different but also very rewarding as I got to make the ‘back-end’ part of web applications. This article described how to make a table in Ruby through migrations, seeding, and how to view it on VSCode. I hope this helped you better understand this aspect of Ruby!