Starting a Rails back end from scratch.

Looking to create a Rails backend from scratch? In this following quick start guide, we’ll cover creating a new API backend, the database and migration, model, and controller files.

Image for post
Image for post

From the console we can run

Alternatively, if you are looking to use postgresql as your database, we can run

Creating resources

A quick way to create your controllers, models, migrations etc, is to use “rails g resource”

Let’s say we have a User model. We can create all the files needed with one line.

This will create

After you create all your models we can run

This will run your migration files.

Now your ready to create your seed data and set your relationship in your model files.

Fullstack Software Engineer

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