Skip to content

Instantly share code, notes, and snippets.

@forelabs
forelabs / ar_arel_wrapper.rb
Created January 9, 2020 10:47 — forked from tokland/ar_arel_wrapper.rb
Simple wrapper over arel
require 'active_record'
require 'arel'
# Ruby-like syntax in AR conditions using the underlying Arel layer (Rails >= 3.0).
#
# What you would usually write like this:
#
# User.where(["users.created_at > ? AND users.name LIKE ?", Date.yesterday, "Mary"])
#
# can now be written like this (note those parentheses required by the operators precedences):