What is Arel? • github.com/rails/arel • “Simplifies generation of complex SQL” You write Ruby, out comes the SQL • dependency of ActiveRecord • can be used together with ActiveRecord
Prerequisites for the examples • ‘Customer’ is an ActiveRecord model • Arel api for a column: Customer.arel_table[:name] • A “convention”: class Customer def self.[](column) arel_table[column] end end Customer[:name]