How to: Upgrade CarrierWave to 3.x
While upgrading CarrierWave from version 0.11.x to 3.x, we encountered some very nasty fails. Below are the basic...
PSA: Be super careful with complex `eager_load` or `includes` queries
TLDR Using .includes or .eager_load with 1-n associations is dangerous. Always use .preload instead. Consider the following ActiveRecord...
Heads up: Quering array columns only matches equally sorted arrays
Given you have an array column like this: create_table "users", force: :cascade do |t| t.integer "movie_ids", default: [], array...
Spreewald, Cucumber: Selector for the nth element
The recommended additional setup of the spreewald gem, a useful set of cucumber steps, includes adding a file for defining...
How to make sure that manual deploy tasks (scheduled in Pivotal Tracker) are executed on deploy (with Capistrano)
We regularly have tasks that need to be performed around a deploy. Be it to notify operations about changed application...
How to work around selenium chrome missing clicks to elements which are just barely visible
Chromedriver (or selenium-webdriver?) will not reliably scroll elements into view before clicking them, and actually not click the element...
Don't use log level :debug in your production environments
You don't want sensitive user data in your logs. Background Rails per default filters sensitive data like...
Upgrade Rails: Awareness list
Disclaimer This card is a collection of guides and things to have in mind when upgrading to a specific version...
Split your parallel tests by execution time and keep execution logs up to date
Both knapsack and parallel_tests have the option to split groups by historic execution time. The required logs for this...
Git restore vs. reset for reverting previous revisions
The git doc states on the difference of these two commands: git-restore[1] is about restoring files in the...
redirect_to and redirect
There are multiple ways to redirect URLs to a different URL in Rails, and they differ in small but important...
Do not use "permit!" for params
Rails' Strong Parameters enable you to allow only specific values from request params to e.g. avoid mass assignment.
Capybara: How to find the focused element
Capybara allows you to filter elements that are focused. page.find(:fillable_field, focused: true) # Filtering only fillable inputs for performance...
Postgres in Alpine docker container: sorting order might differ
In CI test runs I noticed that string sorting order changed after switching from a debian-based PostgreSQL docker image...
Use -webkit-line-clamp to natively truncate long (multi-line) texts with an ellipsis
Note: You won't need this for single lines of text. In this case it is better to just use...
CarrierWave: Processing images with libvips
When you write your next CarrierWave uploader, consider processing your images with libvips instead of ImageMagick. Reasons for libvips
RubyMine and Rubocop: Performing safe autocorrects on save
Ctrl + Alt + S > search "rubocop on save" Under "Inspections", check the highlighted box on rubocop -a Caveat: This adds a...
Balance your texts today with text-wrap: balance
So you have a heading that is just barely wider than the container it should fit into, and it wraps...
Git: Splitting up changes into several commits
Splitting up commits makes the process of reviewing often easier, since you can create several merge requests or review every...
Capo: putting <head> content into the right order
How you order elements in the can have an effect on the (perceived) performance of the page. This script helps...
How to pretty print all values in a Redis database
With this Ruby script you can print all values in a Redis database to your console (derived from this bash...
The numericality validator does not care about your BigDecimal precision
Looking at the source code of the validates_numericality_of validator, it becomes clear that it converts the attribute in...
Preventing users from uploading malicious content
When you allow file uploads in your app, a user might upload content that hurts other users. Our primary concern...
ActiveRecord::Relation#merge overwrites existing conditions on the same column
In Ruby on Rails ActiveRecord::Relation#merge overwrites existing conditions on the same column. This may cause the relation to...