Section 3.0. Introduction Recipe 3.1. Setting Up a Relational Database to Use with Rails Recipe 3.2. Programmatically Defining Database Schema Recipe 3.3. Developing Your Database with Migrations Recipe 3.4. Modeling a Database with Active Record Recipe 3.5. Inspecting Model Relationships from the Rails Console Recipe 3.6. Accessing Your Data via Active Record Recipe 3.7. Retrieving Records with find Recipe 3.8. Iterating Over an Active Record Result Set Recipe 3.9. Retrieving Data Efficiently with Eager Loading Recipe 3.10. Updating an Active Record Object Recipe 3.11. Enforcing Data Integrity with Active Record Validations Recipe 3.12. Executing Custom Queries with find_by_sql Recipe 3.13. Protecting Against Race Conditions with Transactions Recipe 3.14. Adding Sort Capabilities to a Model with acts_as_list Recipe 3.15. Performing a Task Whenever a Model Object Is Created Recipe 3.16. Modeling a Threaded Forum with acts_as_nested_set Recipe 3.17. Creating a Directory of Nested Topics with acts_as_tree Recipe 3.18. Avoiding Race Conditions with Optimistic Locking Recipe 3.19. Handling Tables with Legacy Naming Conventions Recipe 3.20. Automating Record Timestamping Recipe 3.21. Factoring Out Common Relationships with Polymorphic Associations Recipe 3.22. Mixing Join Models and Polymorphism for Flexible Data Modeling |