Skip to content

Instantly share code, notes, and snippets.

View TheScrubsFan's full-sized avatar

Maxim Baidin TheScrubsFan

View GitHub Profile

Arel Cheatsheet on Steroids

A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.

Tables

posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord

Table alias

class User < ApplicationRecord
has_many :interests
has_many :skills, class_name: 'Skil'
ALLOWED_GENDERS = %w[male female].freeze
MIN_AGE = 0.freeze
MAX_AGE = 90.freeze
validates
:name, :patronymic, :email, :age, :nationality, :country, :gender,