~/talk

Active Record Scopes and Arel

Talkat RailsConf 2012 · 2012-04-23..04-25· [ruby-on-rails, databases]
links:none on file
slides:none on file

Argues that using Arel instead of SQL fragments makes ActiveRecord scopes truly composable and database-portable, showing concrete code: Arel table columns with matches produce ILIKE on Postgres and LIKE elsewhere, in accepts arrays or ranges (generating IN or BETWEEN), and combining predicates with or or hash-style where avoids ambiguous column errors when merging scopes. Recommends class methods over lambda scopes for time-dependent or complex queries and mentions Squeel as a nicer predicate DSL.

AI-written summary · about

  1. 0:00History of Rails Querying
  2. 2:11Introduction of named scopes
  3. 4:00Rails 3 querying changes
  4. 5:44Database compatibility issues
  5. 8:21Introduction to Arel
  6. 10:41Using Arel for complex queries
  7. 13:20Advanced Arel and hashes
  8. 15:55Avoiding SQL fragments
  9. 19:28Scope best practices
  10. 22:52Arel predicates and Squeel
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.