Using rack-mini-profiler (with Unpoly)

Posted 9 days ago by Niklas Hä..

Debugging performance issues in your Rails app can be a tough challenge. To get more detailed insights consider using the...

Rails 7.1: Take care of the new production log default to standard out

Posted 10 days ago by Emanuel.

Starting with Rails 7.1 the production logger is set to standard out. For applications running with opscomplete ensure to keep...

Rails: Testing file downloads with request specs

Posted About 1 month ago by Julian.

tl;dr Prefer request specs over end-to-end tests (Capybara) to joyfully test file downloads! Why? Testing file downloads

Chaining Capybara matchers in RSpec

Posted About 2 months ago by Henning Koch.

You can chain multiple Capybara matchers on the page or any element: expect(page) .to have_content('Example Course')

Be careful when checking scopes for blankness

Posted 2 months ago by Dominic Beger.

Today I stumbled across a pretty harmless-looking query in our application which turned out to be pretty harmful and...

Use <input type="number"> for numeric form fields

Posted 3 months ago by Arne Hartherz.

Any form fields where users enter numbers should be an . Numeric inputs have several benefits over : On mobile or tablet...

How to configure Selenium WebDriver to not automatically close alerts or other browser dialogs

Posted 3 months ago by Arne Hartherz.

tl;dr We recommend configuring Selenium's unhandled prompt behavior to "ignore". When running tests in a real browser, we...

Best practices: Writing a Rails script (and how to test it)

Posted 3 months ago by Dominik Schöler.

A Rails script lives in lib/scripts and is run with bin/rails runner lib/scripts/.... They are a simple tool to perform...

Ignore commits when git blaming

Posted 4 months ago by Niklas Hä..

You can ignore certain commits when using git blame with the --ignore-revs-file option. This is handy to ignore...

open-next-failure: An alias to speed up test debugging

Posted 4 months ago by Michael Leimstädtner.

Getting an entire test suite green can be a tedious task which involves frequent switches between the CLI that is...

Gitlab: How to cancel redundant pipelines

Posted 4 months ago by Emanuel.

In the Gitlab settings the flag Auto-cancel redundant pipelines is enabled by default. This auto-cancels jobs that have...

Rails: Pluck across associated tables

Posted 5 months ago by Dennis.

#pluck is commonly used as a performant way to retain single database values from an ActiveRecord::Relation Book.pluck(:title, :price...

A reasonable default CSP for Rails projects

Posted 5 months ago by Tobias Kraze.

Every modern Rails app should have a Content Security Policy enabled. Very compatible default The following "default" is a minimal...

Zeitwerk: How to collapse folders in Rails

Posted 6 months ago by Niklas Hä..

All direct child directories of app are automatically added to the eager- and autoload paths. They do NOT create a...

PSA: Be super careful with complex `eager_load` or `includes` queries

Posted 6 months ago by Tobias Kraze.

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

Posted 6 months ago by Michael Leimstädtner.

Given you have an array column like this: create_table "users", force: :cascade do |t| t.integer "movie_ids", default: [], array...

How to make sure that manual deploy tasks (scheduled in Pivotal Tracker) are executed on deploy (with Capistrano)

Posted 7 months ago by Dominik Schöler.

We regularly have tasks that need to be performed around a deploy. Be it to notify operations about changed application...

Split your parallel tests by execution time and keep execution logs up to date

Posted 7 months ago by Felix Eschey.

Both knapsack and parallel_tests have the option to split groups by historic execution time. The required logs for this...

redirect_to and redirect

Posted 7 months ago by Niklas Hä..

There are multiple ways to redirect URLs to a different URL in Rails, and they differ in small but important...

Do not pass params directly into url_for or URL helpers

Posted 7 months ago by Arne Hartherz.

Rails' url_for is useful for generating routes from a Hash, but can lead to an open redirect vulnerability.

Do not use "permit!" for params

Posted 8 months ago by Arne Hartherz.

Rails' Strong Parameters enable you to allow only specific values from request params to e.g. avoid mass assignment.

Minifying object properties in JavaScript files

Posted 8 months ago by Henning Koch.

An introduction to mangling When you minify ("compress", "optimize") your JavaScript for production, the names of your functions and variables...

CarrierWave: Processing images with libvips

Posted 9 months ago by Henning Koch.

When you write your next CarrierWave uploader, consider processing your images with libvips instead of ImageMagick. Reasons for libvips

Balance your texts today with text-wrap: balance

Posted 9 months ago by Arne Hartherz.

So you have a heading that is just barely wider than the container it should fit into, and it wraps...