Arel: The Ruby Relational Algebra Library
summary
Arel is the Ruby relational algebra engine that replaces fragile SQL string concatenation with an object model for SQL queries and is the foundation inside ActiveRecord in Rails 3. It produces lazy, chainable Relation objects that are immutable, support where/group/order/limit/update_all/delete_all, and execute only on iteration so fragment caching stops extra queries. Arel ships with SQL and in-memory engines, exposes attribute predicates (gt, matches, in, etc.), lets code build complex AND/OR predicates, and enables future engines like Redis or memcache for cross‑engine joins.
AI-written summary · about
chapters (14)
- 0:00Start
- 2:26What is Arel?
- 5:39What's a Relation?
- 6:46Core Operations
- 7:43Closure!
- 8:58Original: Hash queries
- 10:16Rails 2.1: Named scopes
- 12:20Lazy class RubyistsController
- 14:18New Finder Methods
- 16:52Example
- 23:13Exposing the Attributes
- 24:21Compound Predicates
- 25:41Map any relation to a class
- 27:28Map any relation as an association class User Active Records Base
related talks
35mAdvanced aRel: When ActiveRecord Just Isn't Enough
25mActiveRecord can't do it? Arel can!
21mActiveRecord can't do it? Arel can!
28mActive Record Scopes and Arel
17mWrangle Your SQL With Arel
05mHow to use Arel? Wrong answers only!
30mBuilding an ORM with AReL: Walking up the (AS)Tree.
38mTwenty Thousand Leagues Under ActiveRecord
