Chapter 3. Active Record Section 3.0. Introduction Setting Up a Relational Database to Use with Rails Programmatically Defining Database Schema Developing Your Database with Migrations Modeling a Database with Active Record Inspecting Model Relationships from the Rails Console Accessing Your Data via Active Record Retrieving Records with find Iterating Over an Active Record Result Set Retrieving Data Efficiently with Eager Loading Updating an Active Record Object Enforcing Data Integrity with Active Record Validations Executing Custom Queries with find_by_sql Protecting Against Race Conditions with Transactions Adding Sort Capabilities to a Model with acts_as_list Performing a Task Whenever a Model Object Is Created Modeling a Threaded Forum with acts_as_nested_set Creating a Directory of Nested Topics with acts_as_tree Avoiding Race Conditions with Optimistic Locking Handling Tables with Legacy Naming Conventions Automating Record Timestamping Factoring Out Common Relationships with Polymorphic Associations Mixing Join Models and Polymorphism for Flexible Data Modeling Previous Next