In one of my previous blog posts, I explained how to create a full Rails application using the Scaffold generator. However, in many cases, you will need Rails to serve as your backend application that renders APIs to the frontend application. In this blog post, I will show you how to create a backend Rails application as an API.

Create a New Rails Application

As always we will start by creating a new Rails application using rails newcommand. Let’s run the following command in the terminal:

$ rails new rails-application

Running this command will create a full Rails application that would also serve as a…


Photo by Sébastien Jermer on Unsplash

React Router is a library or a package to help you navigate between your React application components. As mentioned in React Router’s Documentation, “React Router is a collection of navigational components that compose declaratively with your application. Whether you want to have bookmarkable URLs for your web app or a composable way to navigate in React Native, React Router works wherever React is rendering — so take your pick!”

In this blog post, I will show you how to use React Router with a code along for a song library. Let’s get started:

Create a New React Project

This is an easy step. All you…


Photo by Joshua Aragon on Unsplash

If you are new to Rails, you might come across Scaffold generator. So what is scaffold generator in Rails? In this blog post, I will show you a code along with an example of how to use it.

First, What is Scaffold?

Scaffolding, also called scaffold or staging is a temporary structure used to support a work crew and materials to aid in the construction, maintenance and repair of buildings, bridges and all other man-made structures.” — Wikipedia

Now that you know what scaffold is in general, you can have an idea of what scaffold is in Rails. A scaffold in Rails is a…


Photo by Bernard Hermant on Unsplash

In one of my previous blogs, I explained how to create your first react-native project. In this blog post, we will create a project that updates the state when typing in a TextInputor by clicking a button.

Create a New Project

We know from the previous react-native blog post the way to create a new project using Expo client to run your app on a web browser or you can even run it on your device. In your terminal run the following command and then when prompt choose blank :

$ expo init counter

After you create a new react native project, if you…


Photo by Joshua Aragon on Unsplash

In one of my previous blogs, I wrote a blog post on how to use the Model generator in Rails. In this blog post, I will explain how to use the Resource generator.

As we said before, generators in Rails is a built-in script that produces many application elements. The Model generator produces a model (class) inside the app/models directory, a migration file inside thedb/migrate directory, in addition to some unit testing files. However, the Resource generator produces more than just these elements. Let’s talk about this in detail.

Resource Generator Command

You can write the command to create your resource specifying the…


Photo by Dane Deaner on Unsplash

What is Scraping in Ruby?

Scraping in Ruby is a way to extract data from web pages so you can use it in your program. We usually scrape data when the website doesn’t provide raw data, APIs for instance, for the information we need. So we just pull the web page to our program and extract some raw data from it.
For example, this web page presents the best 300 movies to watch according to Rotten Tomatoes.


Photo by Ross Sneddon on Unsplash

A big part of Ruby programming is based on making the programmer life’s easier and better. Macros in Ruby were created so programmers don’t write the same things over and over again. So what is a macro in Ruby?!

A macro in Ruby is a piece of code that is responsible for generating other code which could be a new instance method. In my previous blog post, I explained how to write Setter and Getter methods in Ruby. …


Photo by Caspar Camille Rubin on Unsplash

Getter and Setter methods in Ruby are gateways to access class instance variables. In this blog post I will explain how to create a class with getter and setter methods.

Let’s explain what a getter and a setter method in Ruby are!

A Getter method is the only way where you can retrieve the value of an instance variable from outside its class. A Setter method is the only way where you can assign a value to an instance variable from outside its class.

Now that we have an idea on what each one is, let’s explain them using an…


Photo by frank mckenna on Unsplash

A closure is a concept in JavaScript where one function has access to variables that belong to another function. The main thing about these two functions is that one lives inside the other where the inner one has access to the outer one’s variables. A closure is created whenever a function is created.

When a closure is created, it will have three scope chains: its own scope, the outer function scope, and the global scope.

  • It will have access to its own scope where any variable is defined within its body.
  • It will have access to the outer function variables.

Photo by Alok Sharma on Unsplash

Migration in Rails is responsible for creating and editing database tables. To migrate the database changes in rails, run $ rails db:migrate.
Rails will only read the new migration files that have never been migrated before. So once you run a migration file, you can’t go back and change it and run it again. You will have to create a new migration to edit your database.

In this blog post, I will show you how to manually create a migration file in Rails; whether it is a whole new table or fixing an existing table.

Create a table

You will have to create…

Shaqqour

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store