Careful when using Time objects for generating ETags

Posted Over 1 year ago by Arne Hartherz.

You can use ETags to allow clients to use cached responses, if your application would send the same contents as...

Git: Restore

Posted Over 1 year ago by Julian.

tl;dr git checkout is the swiss army of git commands. If you prefer a semantically more meaningful command for...

Git commands to discard local changes

Posted Over 1 year ago by Felix Eschey.

You have uncommited changes (you can always check by using git status), which you want to discard.

RubyMine: Find and Replace with Regex (Capture Groups and Backreferences)

Posted Over 1 year ago by Julian.

tl;dr In RubyMine you can use find and replace with capture groups (.*?) and backreferences $1 (if you have several...

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

JSON APIs: Default design for common features

Posted Over 1 year ago by Niklas Hä..

When you build a JSON API you need to come up with a style to represent attributes, pagination, errors or...

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 Almost 2 years 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...

Debug file system access in a Rails application

Posted About 2 years ago by Tobias Kraze.

It might sometimes be useful to check whether your Rails application accesses the file system unnecessarily, for example if your...

Gem development: recommended gem metadata

Posted About 2 years ago by Daniel Straßner.

The gemspec for gems allows to add metadata to your gem, some of which have a special meaning and are...

Generating an Entity Relationship Diagram for your Rails application

Posted About 2 years ago by Arne Hartherz.

This card explains how to generate an entity relationship diagram for your Rails application. We also show how to limit...

PostgreSQL: "WHERE NOT <column> = '<value>'" statements do not include NULL values

Posted Over 2 years ago by Jakob Scholz.

Sometimes we write plain SQL queries in migrations so we don't have to mock ActiveRecord classes. These two migrations...

Deployment: Merge consecutive commits without cherry-picking

Posted Over 2 years ago by Julian.

You want to deploy new features but the latest commits are not ready for production? Then use git merge master...

Using ngrok for exposing your development server to the internet

Posted Over 2 years ago by Tobias Kraze.

Sometimes you need to access a dev server running on localhost from another machine that is not part of the...

Rails 6.1: where.not changes behaviour from NOR to NAND

Posted Over 2 years ago by Julian.

Since Rails 6.1, if we use where.not with multiple attributes, it applies logical NAND (NOT(A) OR NOT(B)) instead...

RSpec: Define negated matcher

Posted Over 2 years ago by Julian.

You can use RSpec::Matchers.define_negated_matcher to define a negated version of an existing matcher. This is particularly useful...

Caching in Rails < 6.1 may down parts of your application when using public cache control

Posted Over 2 years ago by Dominic Beger.

Proxy caching is a good feature to serve your publicly visible application content faster and reduce load on your servers...

ES6 imports are hoisted to the top

Posted Over 2 years ago by Henning Koch.

From Exploring ES6: Module imports are hoisted (internally moved to the beginning of the current scope). Therefore, it doesn’t...

Ensure passing Jasmine specs from your Ruby E2E tests

Posted Over 2 years ago by Henning Koch.

Jasmine is a great way to unit test your JavaScript components without writing an expensive end-to-end test for...

Using feature flags to stabilize flaky E2E tests

Posted Over 2 years ago by Henning Koch.

A flaky test is a test that is often green, but sometimes red. It may only fail on some PCs...

RSpec: automatic creation of VCR cassettes

Posted Over 2 years ago by Klaus Weidinger.

This RailsCast demonstrated a very convenient method to activate VCR for a spec by simply tagging it with :vcr.

Better numeric inputs in desktop browsers

Posted Over 2 years ago by Arne Hartherz.

You want to use fields in your applications. However, your desktop users may encounter some weird quirks: Aside from allowing...

Event delegation (without jQuery)

Posted Over 2 years ago by Henning Koch.

Event delegation is a pattern where a container element has a single event listener that handles events for all descendants...

Capybara can find links and fields by their [aria-label]

Posted Over 2 years ago by Henning Koch.

Sometimes a link or input field has no visible label. E.g. a text field with a magnifying glass icon 🔎 and...