chapter 3 in https://www.railstutorial.org/book/beginning