第3回 ActiveRecordを使ったソースコードを読もう 倉貫 義人 松村 章弘 TIS株式会社 SonicGarden 2009/1/28 優れたプログラマはコードを書くのと同じくらい、コードを読みこなせなくてはならない。優れたコードを読むことで、自身のスキルも上達するのだ(編集部) これまでの2回の記事で、Railsアプリケーションの基本的な構成と、テスティングフレームワークであるRSpecを使ったソースコードのコードリーディングを行ってきました。今回は、RailsのキモでもあるDBアクセス処理の部分を扱うActiveRecordを深く掘り下げてコードリーディングを行います。 ActiveRecordとは、まさしく同名の“Active Record”というDBアクセスに関するデザインパターンを実装したライブラリです。データベースのテーブルをクラスとしてビジネスロジックを持たせ、テー