Checklist ✅ for Rails Application 📋

YU SHI
5 min readMar 10, 2021

When we create an application by using Ruby on Rails, we don’t just start making whatever app that comes to our mind. It will make us very confused. And things will get very complicated. We don’t want this to happen when we make our Rails app. We want to do the app step by step. A checklist will help us to stay organized in managing various tasks. We will be sure that no steps in a process will be skipped or forgotten.

In this article, we are going to make a checklist for Rails app 📋

1. Draw out the entity-relationship diagram (ERD) for your Rails app (e.g. image below)

  • How many models do you have? (e.g. User, Pet, UserPet)
  • What is the models’ relationship? (belongs_to? or has_many?)
  • Each model’s attribute (e.g. name:string, description:string, age:integer)
  • What is in the controller and view for each model? (e.g. index, new, show, create, edit, update, destroy)

2. Start the Rails app

  • Run the ‘rails new name_of_app’ command in the terminal
  • It will creates a new Rails application with a default directory structure

3. Open the app on your text editor

  • Run the server(type ‘rails s’ command in the terminal) to check if the app work on the website
  • Yay! You’re on Rails!
  • Run ‘bundle install’ command in the terminal. You can always add a gem later that you want to use while you are working on the app(e.g. gem ‘faker’, gem ‘bcrypt’, gem ‘tty-prompt’, gem ‘colorize’.) You run the ‘bundle install’ again after you add the new gem.

4. Start to generate the model, controllers, and view files

  • Run the ‘rails g model User name age:integer bio’ command (this will generate the User model, migration file, and table for you.) We don’t need the ‘:string’ for name and bio because Rails magic ✨ (Rails will make every attribute as a string if you don’t specify.) — Model is singular
  • Run the ‘rails g controller Users’ command to generate the controller. Also you can run ‘rails g controller Users index new show create edit destroy’ command (this will make all the method and view file for you)
  • There is another command which is even faster ‘rails g resource User name age:integer bio ’. This all depends on which model you have. You can do ‘rails g resource UserPet user:belongs_to pet:belongs_to’. Don’t worry about the plural if you are using ‘rails g resource’ because Rails magic ✨ . It will generate all the files for you:
  • A model file
  • A migration file
  • A controller file
  • Corresponding view file

5. Write out all the relationships for each model

For example:

User model

  • has_many :user_pets, dependent: :destroy
  • has_many :pets, through: :user_pets

UserPet Model

  • belongs_to :pet
  • belongs_to :user

Pet model

  • has_many :user_pets, dependent: :destroy
  • has_many :users, through: :user_pets

6. Check all the model relationships and tables before you run ‘rails db:migrate’ command, because you don’t want to do the actual jobs in the terminal. It’s because you can’t just change the column name or delete the table in the file. You have to do it in the terminal if you want to delete the column or table.

  • Run ‘rails g migration DropTablename’ command to delete table
  • Run ‘rails g migration RemoveAgeFromUser age:integer’ to remove column
  • After delete the table or column, then run the ‘rails db:migrate’ again

7. After you did everything above, then make sure to check the schema to see if every table has the correct column. You have to look at your schema to make you seed data(e.g. image below)

8. Run ‘rails db:seed’ command in the terminal after you write out all your seed data

9. Run ‘rails c’ (go to the console) to test all the model relationships. Make sure everything is working after you seeded the data

10. Start writing out all the methods in the controller (index, new, show, create, edit, destroy). The “index new create show edit destroy” will create actions in your controller and view files for each of them

11. After you write out everything in the controller, then update the routes for every action.(e.g. image below) You also can use ‘resources :videogames’, but I highly recommend writing all the routes out.

12. Set up your view files after the controllers and routes are done

13. Now you can start to run ‘rails s” to check out each view on the server. The server will tell you what is going on and if there is an error. Some errors might be easy to fix and some might take a little longer to figure out

I hope this article helps everyone make their Rails application successfully. If you think I explained something wrong or unclear, or if you think I am missing some steps, please don’t hesitate to leave a comment. Thank you so much!

--

--

YU SHI

Software Engineer experienced in JavaScript, React, and Ruby on Rails based programming. Currently looking for an opportunity.