Let's try to implement the behavior of libraries like paranoia and acts_as_paranoid in Postgres! tldr - jump to the summary below! We'll make it possible to restore deleted user accounts! Let's assume that…
Let's try to mimic the following belongs_to relationship with counter_cache behavior in Postgres! tldr - jump to the summary below! class Comment < ActiveRecord::Base belongs_to :post, counter_cache: true end class…
Let's try to port some ActiveRecord validations to Postgres using constraints! validates_presence_of class User < ActiveRecord::Base validates_presence_of :email end ALTER TABLE users ALTER COLUMN email SET NOT NULL; ALTER TABLE…
The Enumerable#each_with_object method behaves very similarly to Enumerable#inject! There are only a couple of differences! The block arguments are reversed The inject method passes the block arguments in the following order…
Valid Ruby (the only valid line of code in this post) before_validation(on: :create) { contact.email ||= email } Drop braces and use a stabby proc before_validation(on: :create) -> contact.email ||= email Drop…
tldr; Let's get started I've heard a lot about Docker over the past year but haven't really dived into it much until recently. So far the experience has been amazing! I've found the technology to…