Understanding database Indexes in PostgreSQL

Posted 12 months ago by Michael Leimstädtner.
blog.mastermind.dev

I found the linked article very helpful to refresh my understanding of database indexes. As a small bonus, it includes...

Simple Form: Rendering errors without an appropriate attribute

Posted About 1 year ago by Emanuel.

Usually you add errors to :base in ActiveRecord, in case no appropriate attribute could be used to add the error...

Rails: Assigning associations via HTML forms

Posted About 1 year ago by Emanuel.

Let's say we have posts with an attribute title that is mandatory. Our example feature request is to tag...

Beware when using ActiveSupport time and date calculation methods

Posted About 1 year ago by Bruno Sedler.

Rails Active Support provides some helpful methods for calculating times and dates, like Duration#ago or Duration#from...

Rails: Composing an ETag from multiple records

Posted About 1 year ago by Henning Koch.

Rails offers the fresh_when method to automatically compute an ETag from the given record, array of records or scope...

Rails: Your index actions probably want strict_loading

Posted About 1 year ago by Henning Koch.

By activating strict_loading you force developers to address n+1 queries by preloading all associations used in the index...

Rails migration: Changing a column type without losing the content

Posted About 1 year ago by Jakob Scholz.

The change_column method for rails migrations support casting with a custom SQL statement. This allows us to change a...

Story Checklist Template

Posted About 1 year ago by Felix Eschey.

This is an story checklist I use to work on stories. For this purpose I extracted several cards related to...

Rails Partials

Posted About 1 year ago by Niklas Hä..

Rails partials have a lot of "hidden" features and this card describes some non-obvious usages of Rails Partials.

Rails: Using database default values for boolean attributes

Posted About 1 year ago by Emanuel.

In the past we validate and set default values for boolean attributes in Rails and not the database itself.

Carrierwave: Custom file validations inside custom Uploaders

Posted About 1 year ago by Jakob Scholz.

Carrierwave's BaseUploader can have some validations that you can use by overriding a certain method, which's expected name...

Rails: Encrypting your database information using Active Record Encryption

Posted About 1 year ago by Emanuel.

Since Rails 7 you are able to encrypt database information with Active Record. Using Active Record Encryption will store an...

Postgres: DISTINCT ON lets you select only one record per ordered attribute(s) for each group

Posted Over 1 year ago by Felix Eschey.
geekytidbits.com

To retrieve only unique combinations of the selected attributes: You can omit rows, where all selected columns are equal with...

Signed URLs with Ruby on Rails

Posted Over 1 year ago by Henning Koch.
kukicola.io

Using ActiveRecord's #signed_id and .find_signed methods you can create URLs that expire after some time. No conditionals...

Why Sidekiq Jobs should never be enqueued in an `after_create` or `after_save` callback

Posted Over 1 year ago by Tanja.

When an object is created / updated, various callbacks are executed in this order: before_validation after_validation before_save

Ruby object equality

Posted Over 1 year ago by Daniel Straßner.
ruby-doc.org

TLDR if you define a equality method for a class you must also implement def hash. Ruby has a lot...

Bookmarklet: cards Markup Link Bookmarklet

Posted Over 1 year ago by Daniel Straßner.

The cards editor has a feature "Cite other card" to create links to other cards in the same deck as...

Rails: Use STI in Migration

Posted Over 1 year ago by Julian.

tl;dr You should decouple migrations from models by embedding models into the migration. To use STI in this scenario...

Jasmine: Creating DOM elements efficiently

Posted Over 1 year ago by Henning Koch.

Jasmine specs for the frontend often need some DOM elements to work with. Because creating them is such a common...

Variable fonts: Is the performance trade-off worth it? - LogRocket Blog

Posted Over 1 year ago by Henning Koch.
blog.logrocket.com

Variable fonts are popular for two reasons: they expand design possibilities and improve website performance. While the former statement is...

Chrome DevTools: Treasure (Overview)

Posted Over 1 year ago by Julian.

tl;dr The Chrome DevTools are a neat collection of tools for the daily work as a web developer. If...

ActiveType::Object: Be careful when overriding the initialize method

Posted Over 1 year ago by Jakob Scholz.
github.com

ActiveType::Object inherits from ActiveRecod::Base and is designed to behave like an ActiveRecord Object, just without the database...

Debug flaky tests with an Unpoly observeDelay

Posted Over 1 year ago by Niklas Hasselmeyer.

Unpoly's [up-observe], [up-autosubmit] and [up-validate] as well as their programmatic variants up.observe() and up.autosubmit...

Rails: Validations of Dates, Numerics and Strings with ComparisonValidator

Posted Over 1 year ago by Julian.

tl;dr Since Rails 7+ you can use ComparisonValidator for validations like greater_than, less_than, etc. on dates, numerics...