How to skip all callbacks for all models in Rails
Different approaches for avoiding all callbacks on a Rails Active Record model

Search for a command to run...
Series
Short Ruby or Ruby on Rails tips or Today I Learned moments
Different approaches for avoiding all callbacks on a Rails Active Record model

If you want to freeze strings in Ruby there are at least two ways to do this: 1) Adding the magic comment at the beginning of the file # frozen_string_literal: true 2) Calling .freeze on the string that you want to freeze a = "this is a frozen strin...
How to get the class name To get the class name: class User def call = puts self.class.name end User.new.call #=> User This will work even if the name is namespace inside a module: module Authenticated class Visitor def call = puts self.cla...
Examples of creating an enum type, renaming a value, deleting a value

How to create a raw SQL to update in Rails different values for each record in one single query

Context Let's say that you have two array of hashes: a = [ { initial: "a", email: "a@example.com" }, { email: "b@example.com", initial: "b" }, { initial: "c", amount: 3, email: "c@example.com" } ] and b...
