4.1. Howto for this Chapter

This chapter is a self-contained unit. But the knowledge provided in Chapter 2, Ruby Basics and Chapter 3, First Steps with Rails is required. Without these basics, you will not have any fun with this chapter!
Rails newbies should read this chapter once from beginning to end. Please take your time. This chapter is important!

Buy the new Rails 5.1 version of this book.

This chapter is only about ActiveRecord. So I am not going to integrate any tests (see Chapter 7, Tests), to keep the examples as simple as possible.

Not in the Mood for SQL?

Occasionally, I will discuss SQL code created by ActiveRecord methods. If you are not interested in SQL: just read over it and don't worry. The beauty of ActiveRecord is that you do not need to think about it. For everyone else, my comments provide better understanding of the optimization processes going on in the background.