Rails: Different flavors of concatting HTML safe strings in helpers

Posted 9 days ago by Emanuel.

This card describes different flavors for concatting HTML safe strings in a helper method in Rails. You might want to...

Using rack-mini-profiler (with Unpoly)

Posted 17 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 18 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 2 months 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')

Accessibility: Making non-standard elements interactive

Posted About 2 months ago by Michael Leimstädtner.
developer.mozilla.org

A common cause of non-accessible web pages are elements that were made interactive via JavaScript but cannot be focused...

Be careful when checking scopes for blankness

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

Element.animate() to animate single elements with given keyframes

Posted 4 months ago by Nico Winkler.
developer.mozilla.org

Today I learned that you can animate HTML elements using the Web Animation API's method .animate(keyframes, options) (which...

SASS: Adding, removing and converting units

Posted 4 months ago by Dominik Schöler.
sitepoint.com

Multiply by 1x the unit: $number = 13 $length = $number * 1px // => 13px Removing a unit

RubyMine: Real-time Collaborating in the IDE

Posted 4 months ago by Dominik Schöler.
jetbrains.com

RubyMine has a collaboration feature called "Code With Me". Using it, you can invite someone into your local editor to...

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

Using Rationals to avoid rounding errors in calculations

Posted 5 months ago by Martin Schaflitzl.
ruby-doc.org

Ruby has the class Rational which allows you to store exact fractions. Any calculation on these variables will now use...

A reasonable default CSP for Rails projects

Posted 6 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 8 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...