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...

Signed URLs with Ruby on Rails

Posted About 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 About 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...

Statistics and Reports on Web Performance Optimization

Posted Over 1 year ago by Dominik Schöler.
wpostats.com

Case studies and experiments demonstrating the impact of web performance optimization (WPO) on user experience and business metrics.

Careful: `fresh_when last_modified: ...` without an object does not generate an E-Tag

Posted Over 1 year ago by Arne Hartherz.

To allow HTTP 304 responses, Rails offers the fresh_when method for controllers. The most common way is to pass...

Rails: Custom validator for "only one of these" (XOR) presence validation

Posted Over 1 year ago by Arne Hartherz.

For Rails models where only one of multiple attributes may be filled out at the same time, there is no...

Creating a Rails application in a single file

Posted Over 1 year ago by Arne Hartherz.
greg.molnar.io

Greg Molnar has written a neat article about creating a single-file Rails app. This is not meant for production...

Git: removing feature branches on merge

Posted Over 1 year ago by Dominik Schöler.

When working with feature branches, stale branches pile up over time. It's best to remove them right after merge...

Rails: Fixing the memory leak / performance issues in prepend_view_path

Posted Over 1 year ago by Dominik Schöler.

Recently we detected a memory leak in one of our applications. Hunting it down, we found that the memory leak...

A short overview of common design patterns implemented within Rails

Posted Over 1 year ago by Emanuel.
paweldabrowski.com

The linked content includes a few design patterns implemented with Ruby on Rails. What is the card indented to achieve...