Ruby: Find the most common string from an array

Find the most frequent string in an array without failing on empty input; the approach uses grouping and returns the first value from the largest group.

ActiveRecord: When aggregating nested children, always exclude children marked for destruction

Nested form deletions can inflate aggregated totals when child records marked for removal are still counted. marked_for_destruction? filters them out before saving.

Whenever: Don't forget leading zeros for hours!

Whenever can misread 24-hour times without a leading zero, turning 3:00 into 3pm instead of 3am. chronic_options can switch parsing to a 24-hour clock.

A nicer way to run RSpec and/or Cucumber

Convenience scripts streamline RSpec and Cucumber runs with bundle exec, parallel execution, spinner support, and a full test check against regressions.

Aspect Oriented Programming in Ruby

Integrating cross-cutting concerns in Ruby can reduce duplication and keep logging, security, and other shared behavior separate from core business logic.

Random list of ActiveSupport goodies

Handy ActiveSupport helpers add callbacks, message signing and encryption, ordered options, array wrapping, deep hash merging, whitespace squishing, and zone-aware current time.

Live CSS / view reloading

Automatic browser refresh for stylesheet and view changes reduces manual reloads during front-end work and keeps page updates visible immediately.

Pattern: Disabling a certain feature in tests

Integration tests often break on cookie banners or captchas. A test-only switch disables them by default while allowing targeted reactivation for specific cases.

Automatically build sprites with Lemonade

How it works

See the lemonade descriptions.

Unfortunately, the gem has a few problems:

  • it does not work with Sass2
  • it always generates all sprites when the sass file changes, which is too slow for big projects
  • it expects a folder structure quite different to our usual

All these problems are solved for us, in our own lemonade fork. This fork has since been merged to the original gem, maybe we can use t...

Why belongs_to/has_many cannot overwrite methods with the same name

ActiveRecord association macros do not replace existing instance methods with the same name, so custom methods can still shadow belongs_to and has_many accessors.

How to open files from better_errors with RubyMine on Linux

RubyMine rubymine:// links can fail on GNOME/Linux, blocking better_errors from opening source files in the editor. A custom desktop handler and BETTER_ERRORS_EDITOR_URL make file jumping work.

RSpec: Using helpers in view specs

View specs can crash on undefined helper methods; enabling config.action_controller.include_all_helpers or including helper modules makes view rendering work.

How to deal with "invalid %-encoding" error in application for malformed uri

Malformed request URIs can raise invalid %-encoding and break the app before routing. A middleware can return 400 Bad Request instead of ArgumentError or ActionController::BadRequest.

Whenever requires you to set the application attribute in the Capistrano config

Whenever needs application set in Capistrano so cron entries keep a stable identifier and do not accumulate duplicate jobs across deploys.

Debugging Webpacker config

Webpacker configuration can be hard to inspect when builds misbehave; dumping the environment, using browser or Node debugging, and emitting warnings help reveal the active webpack settings.

Speed up better_errors

Better Errors can become very slow in development when large objects are inspected and rendered. Limiting huge inspect output improves error-page performance.

Stop writing "require 'spec_helper'" in every spec

Configure .rspec to load spec_helper or rails_helper automatically, avoiding repeated require lines in every spec and making parallel test setups work with .rspec_parallel.

Deutsche Bahn: Show details of past rides

DB BAHN order numbers on credit card statements can be used to look up details of past rides on the Deutsche Bahn ticket portal.

Disable text-transforms in Selenium tests

text-transform: uppercase can make Selenium assertions flaky and break umlaut handling; disabling transforms in tests improves reliable label text matching.

Consul 0.4.0 released

Consul 0.4.0 adds temporary power switching, support for Ruby collections and arbitrary objects as powers, and drops the ActiveSupport::Memoizable dependency.

Preparing your test database: mind the differences

Test database setup can drift from development when schema dumps omit SQL-specific details; choose the right Rake task to keep structure, charset, and collation aligned.

Mysql::Error: BLOB/TEXT column can't have a default value

MySQL 5.6 rejects default values on BLOB and TEXT columns, blocking migrations that rely on them. Adjust the migration, move defaults into the application, or temporarily change sql_mode.

Capistrano task to tail remote application logs of multiple servers

Monitor logs across multiple app servers from one terminal and avoid missing per-host errors; LOG selects another file, and terminal line truncation can hide long entries.

How to make programming hard for yourself

For all of my professed admiration of Ruby on rails, I personally don't think that easier and more productive CRUD application writing will shake things up. I personally care very much about writing applications in a tenth of the time, but using Rails is like listening to Jaco Pastorius. The real learning experience comes when you try to duplicate the feat.