Ruby on Rails: Get More From ActiveRecord

0
Join & Subscribe
LinkedIn Learning
Free Trial Available
English
Certificate Available
4-5 hours worth of material
selfpaced

Overview

Get more from Ruby on Rails ActiveRecord and leverage shortcuts and techniques to make database code more efficient.

Ready to speed up Ruby on Rails development? Understanding how ActiveRecord is used to create, update, and retrieve data in a relational database is fundamental to writing more efficient, object-oriented code. This course helps you understand the basics of ActiveRecord and leverage shortcuts and techniques to make data migrations faster and more powerful. Kevin Skoglund reviews the basics of working with database records, and shows how to use ActiveRecord queries to locate records faster. He also shows how to use callbacks to automate functionality when objects are saved or deleted, and create associations between ActiveRecord models to streamline common operations. By the end of the course, you will have the skills you need to write concise, high-performance Rails code that eliminates the need to deal with SQL and other tedious database queries.

Syllabus

Introduction
  • Welcome
  • How to use the exercise files
1. Database Migrations
  • Create a database
  • Migration shortcuts
  • The change method
  • Write reversible code
  • Irreversible migrations
  • Revert migrations
  • Create a join table
  • Control migration output
  • Dump the database schema
  • Define seed data
2. CRUD Methods
  • Create records with a block
  • Update multiple records
  • Delete multiple records
  • Touch records
  • Toggle attribute values
  • Increment and decrement counters
3. Dirty Objects
  • Track changes to objects
  • Track changes to attributes
  • Restore attributes
4. Query Interface
  • Other find methods
  • Select partial record data
  • Calculations
  • Negative queries
  • Or queries
  • Retrieve records in batches
  • Default scopes
  • Replace scopes and conditions
  • Join tables
  • Distinct records
  • Left join tables
  • Eager loading
5. Delegations
  • Delegate attributes
  • Set a prefix
  • Without a related object
6. Callbacks
  • Callback basics
  • Conditional callbacks
  • Around callbacks
  • Other callbacks and tips
7. Associations
  • Review
  • Use queries with associations
  • Destroy associated records
  • Touch associated records
  • Counter caches
  • Build records on an association
  • Self-referential associations
  • Single table inheritance
  • Polymorphic associations
Conclusion
  • Next steps

Taught by

Kevin Skoglund