Postgres: DISTINCT ON lets you select only one record per ordered attribute(s) for each group

PostgreSQL DISTINCT ON keeps one ordered row per group, useful for latest-per-user queries and other group-wise maximum results when plain DISTINCT is not enough.

How to send HTTP requests using cURL

Send HTTP requests from the command line with curl, including custom methods, form data, and basic authentication.

Haml Whitespace Preservation (or: Fixing Textarea Indentation in Haml)

Haml indentation can leak into preformatted text and textareas, adding unwanted leading spaces. Using ~ instead of = preserves whitespace without extra indentation.

8 steps for fixing other people's code

Making fixes in someone else’s GitHub repository is easier with modern open source tools, but pull requests and branch workflow still need care.

New gem: Rack::SteadyETag

Rack::SteadyETag makes HTML caching effective by keeping ETags stable when only CSRF tokens or CSP nonces change.

How to migrate CoffeeScript files from Sprockets to Webpack(er)

Migrating CoffeeScript from Sprockets to Webpacker can keep existing classes and dependencies working by adding coffee-loader and adjusting imports and global namespace exposure.

A saner alternative to SimpleForm's :grouped_select input type

SimpleForm's :grouped_select can be awkward when you already have a flat collection and need grouped options. A group_by extension makes optgroup labels easier to derive.

Ruby: Debugging a method's source location and code

Find where a Ruby method is defined and inspect its implementation; Method#source_location reveals file and line, while method_source can return the method body.

ActiveRecord: Query Attributes

attribute? often checks presence like attribute.present?, but numeric values and associations behave differently; 0 can be false for ActiveRecord query attributes.

Transfer records to restore database entries (with Marshal)

Move exact database records between systems by serializing Ruby objects with Marshal and Base64 when a direct export/import needs to preserve IDs and state.

Do not forget mailer previews

Mailer previews often break when mailer code changes, and automated checks can catch missing updates before they reach development workflows.

Always store your Paperclip attachments in a separate folder per environment

Paperclip attachments can collide across development, test, and parallel test processes when they share one storage tree. Separate environment-specific paths prevent overwritten files and missing test data.

makandra/gemika: Helpers for testing Ruby gems

A library for testing a Ruby gem against multiple Ruby, dependency and database combinations, with shared local and CI setup for full permutation coverage.

Gem development: When your specs don't see dependencies from your Gemfile

Bundler does not auto-require gems, so specs may miss dependencies unless the environment calls Bundler.require; direct dependencies still must be required by the gem itself.

How to make Webpacker compile once for parallel tests, and only if necessary

Compile Webpacker assets once in parallel test runs and skip recompilation when files are unchanged, avoiding duplicate work and Capybara timeouts.

Perform Sidekiq jobs immediately in development

Run Sidekiq jobs synchronously in development to avoid a separate worker process and benefit from code reloading.

How to: Solve gem loaded specs mutex

Ruby 1.8.7 test runs can fail with Gem::LOADED_SPECS_MUTEX NameError under older Bundler; Bundler 1.16.1 resolves it.

Webpacker: Configuring browser compatibility

Browser support in Webpacker depends on both Babel and UglifyJS; mismatched settings can break legacy browsers like IE11 even when JavaScript is transpiled.

Mock the browser time or time zone in Selenium features

Selenium browser tests see real system time unless the client clock is patched; timemachine.js and Timecop keep browser time aligned, while TZ can align the process time zone.

Postgresql: Paginate and count in one query using window functions

High-latency pagination queries can be reduced to one PostgreSQL statement by using COUNT(*) OVER() to return page rows and total rows together.

Spec "content_for" calls in helpers

RSpec helper specs can leak content_for state between examples, making repeated checks fail. A fresh helper instance avoids stale instance variables.

Force absolute URLs for parts of a view or controller

Generate full url_for links only within selected view or controller blocks, with temporary opt-out and optional fixed host. Asset URLs remain unchanged.

Chromedriver: Connect local chromedriver with docker

Remote Chrome debugging in Docker is awkward when integration tests need a browser you can inspect. SSH port forwarding can expose a local chromedriver inside the test container.

Using the Ruby block shortcut with arguments

Passing arguments to Ruby’s block shorthand makes map(&:method) usable for nested lookup and JSON extraction without full block syntax.