Ruby on Rails: Get More From ActiveRecord
4h 31mAdvanced2017-01-27
Authors

Kevin Skoglund
Founder of NovaFabrica
Course details
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.
Learning objectives
Migrating databases
Creating, updating, and deleting records
Tracking changes to objects and attributes
Writing queries
Delegating attributes
Callbacks
Working with associations
Learning objectives
Migrating databases
Creating, updating, and deleting records
Tracking changes to objects and attributes
Writing queries
Delegating attributes
Callbacks
Working with associations
Skills covered
Ruby on RailsFront-End Web DevelopmentWeb DevelopmentOpen SourceDeep Dive (X:Y)
Concepts
0. Introduction
- 01 - Welcome
- 02 - How to use the exercise files
1. Database Migrations
- 03 - Create a database
- 04 - Migration shortcuts
- 05 - The change method
- 06 - Write reversible code
- 07 - Irreversible migrations
- 08 - Revert migrations
- 09 - Create a join table
- 10 - Control migration output
- 11 - Dump the database schema
- 12 - Define seed data
2. CRUD Methods
- 13 - Create records with a block
- 14 - Update multiple records
- 15 - Delete multiple records
- 16 - Touch records
- 17 - Toggle attribute values
- 18 - Increment and decrement counters
3. Dirty Objects
- 19 - Track changes to objects
- 20 - Track changes to attributes
- 21 - Restore attributes
4. Query Interface
- 22 - Other find methods
- 23 - Select partial record data
- 24 - Calculations
- 25 - Negative queries
- 26 - Or queries
- 27 - Retrieve records in batches
- 28 - Default scopes
- 29 - Replace scopes and conditions
- 30 - Join tables
- 31 - Distinct records
- 32 - Left join tables
- 33 - Eager loading
5. Delegations
- 34 - Delegate attributes
- 35 - Set a prefix
- 36 - Without a related object
6. Callbacks
- 37 - Callback basics
- 38 - Conditional callbacks
- 39 - Around callbacks
- 40 - Other callbacks and tips
7. Associations
- 41 - Review
- 42 - Use queries with associations
- 43 - Destroy associated records
- 44 - Touch associated records
- 45 - Counter caches
- 46 - Build records on an association
- 47 - Self-referential associations
- 48 - Single table inheritance
- 49 - Polymorphic associations
Conclusion
- 50 - Next steps