DEV Community

Cover image for Bye bye react, rails is my new friend-EP:0
Abhinav Sehgal
Abhinav Sehgal

Posted on

Bye bye react, rails is my new friend-EP:0

I am learning ruby and rails these days. This blog is being written to force me to explain what I am doing. Else I often find I go in an autopilot sort of mode where I am doing things but not really understanding what's going on.

So let's get started. Btw I am learning ror from the ordin project.

Initial Setup

It involved three steps:

  1. creating the app
rails new {insert_your_app_name}
Enter fullscreen mode Exit fullscreen mode
  1. creating something called templates(don't know yet what it is)
rails generate scaffold car make:string model:string year:integer
Enter fullscreen mode Exit fullscreen mode
  1. migrate db(also don't know but sounds heavy and sexy)
rails db:migrate
Enter fullscreen mode Exit fullscreen mode

Fire up the app

Ok so now the order is to run the app

rails server
Enter fullscreen mode Exit fullscreen mode

I am assuming this is the same thing as doing npm run start.

Boom, the site is loaded.

If I go over to the /cars route there is some stuff. Ok, so I can create, edit and delete cars. Interesting. A lot for a one command if you ask me.

Alrighty, now it was mentioned in the lesson to push this to a git repo. It was basic git stuff, so does not makes sense to document it here.

So now the lesson is getting real. They about to explain some web concepts. Buckle up.


Its a protocol. Which to me is a fancy way of saying "follow these bunch of rules or you are screwed". So the http is about the rules of structuring the request-and-response.

Look at this cool diagram. Interesting thing on http/2.0 is you can ask for both the script and style file at the same time.



REST says that mainly you want to do seven things with a resouce. A resouce is basically a thing in the database. Let's say the resource is a blog.

  1. Get all the blogs
  2. Get a single blog
  3. Get a "create a blog" page
  4. Send the data from "create a blog" page to create a blog in db.
  5. Get a "edit a blog" page
  6. Send the data from "edit a blog" page to update a blog in db.
  7. Delete a blog


It has four parts, let me expain it via an example.

  1. Protocol: https
  2. Domain:
  3. Path: /search
  4. Paramters: q=what+is+a+url


It's a way to arhictect your app. The controller talks to both the model and the view and viceversa.

  • Models do the grunt work
  • Views make sure to look pretty
  • Controller is the middle man between the two and does not like to do much work


When you are on a website and you click thier "about us" page
and send a request to a server, the server treats each request as a completely new user. This is because HTTP is stateless. Unless you also send some cookies along with the request.

They are little bits of data that you send to the server along with every request. It allows the server to identify you and any previous requests you made.

It preserves the state of your session.


Once a website stores the cookies, a session starts. It helps you avoid logging again and again, remember some of your settings of the website etc.

Once the cookies are gone, the session ends.


It deals with WHO you are.


It deals with what a user is ALLOWED to do.

Top comments (0)