#pluck is commonly used as a performant way to retain single database values from an ActiveRecord::Relation Book.pluck(:title, :price...
Added: State machine can now use the :prefix-option to avoid name collision if you define multiple state machines on...
Getting CSS (and JS) live reloading to work in a esbuild / Rails project is a bit of a hassle, but...
Make sure that you use the correct property when editing an HTML attribute. Using innerHTML with unsafe arguments makes your...
If you ever need to restore exact records from one database to another, Marshal might come in handy. Marshal.dump is...
The sprintf method has a reference by name format option: sprintf("% d : % f", { :foo => 1, :bar => 2 }) # => 1 : 2.000000
Ruby has the class Rational which allows you to store exact fractions. Any calculation on these variables will now use...
Every modern Rails app should have a Content Security Policy enabled. Very compatible default The following "default" is a minimal...
The old Chrome downloads bar had several advantages over the new subtle downloads dropdown: see all (many, at least) downloads...
While upgrading CarrierWave from version 0.11.x to 3.x, we encountered some very nasty fails. Below are the basic...
All direct child directories of app are automatically added to the eager- and autoload paths. They do NOT create a...
On the Rails console, assigning an object to a variable can lead to this strange error (without stacktrace): irb > recipient...
TLDR Using .includes or .eager_load with 1-n associations is dangerous. Always use .preload instead. Consider the following ActiveRecord...
In the discussion of the difference between include and extend in Ruby, there is a misconception that extend would add...
Most of our applications use CarrierWave for file uploads. CarrierWave has an integrated processing mechanism for different file versions with...
I recently stumbled over a problem that my feature tests broke in CI because of a mismatching chromedriver version.
Given you have an array column like this: create_table "users", force: :cascade do |t| t.integer "movie_ids", default: [], array...
View specs are a powerful tool to test several rendering paths by their cases instead of using a more costing...
The recommended additional setup of the spreewald gem, a useful set of cucumber steps, includes adding a file for defining...
We regularly have tasks that need to be performed around a deploy. Be it to notify operations about changed application...
Do you remember finding where a method is defined? I recently learned from a senior colleague that Method objects are...
The linked rbenv plugin rbenv-each is very helpful to keep QoL gems up to date that are not part...
Chromedriver (or selenium-webdriver?) will not reliably scroll elements into view before clicking them, and actually not click the element...
You don't want sensitive user data in your logs. Background Rails per default filters sensitive data like...