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!


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.

Taste Blood

This book is aimed at beginners. So this chapter describes the basics for using ActiveRecord. I could easily have written a book twice as thick as this one on ActiveRecord alone. I hope this chapter will get you hooked and encourage you to find out more about this topic on your own in the Rails documentations (see Appendix A, Further Rails Documentation).


One of my best buddies when developing Rails applications is the Tab key. Whenever you are looking for a method for a particular problem, recreate it in the Rails console and then press the Tab key twice to list all available methods for the corresponding class. The names of the methods are usually self-exlanatory.

Updates about this book will be published on my Twitter feed.