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.

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.

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.

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.

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.

Perform Sidekiq jobs immediately in development

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

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.

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.

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.

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.

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.

Always show all form errors during development

Forms can fail validation without visible feedback when the offending field has no input. A development-only error box keeps all form errors visible without leaving debug markup behind.

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.

Install RubyMine under Ubuntu

RubyMine on Ubuntu can be installed as a snap with automatic updates or set up manually from the legacy archive. Configuration stays in ~/.config/JetBrains/RubyMine<version> with classic confinement.

Caution: `.includes` can make `.ids` non-unique.

includes can duplicate primary keys in ids when loading associated records, causing unexpected non-unique results; preload keeps the ids list stable.

Checking database size by row count

Quickly gauge which database tables are growing unnoticed by checking approximate row counts in PostgreSQL or MySQL.

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.

How to disable cookies in cucumber tests

Capybara has no built-in switch for disabling cookies in browser tests; a small Rack middleware can strip request cookies so scenarios can verify sign-in failures without them.

How to fix gsub on SafeBuffer objects

html_safe strings lose $1 and other match variables inside gsub blocks. A SafeBuffer override can restore access to capture groups during replacements.

How to remove properties of ActiveRecord scopes

unscope removes selected ActiveRecord scope constraints such as where and order, while unscoped returns an entirely unconstrained relation.