Rails: Testing the number of database queries
N+1 queries and excessive eager loading can be caught by asserting exact database query counts in specs with the make_database_queries RSpec matcher.
Opening a zipped coverage report with one click
Make zipped coverage reports open directly in a browser from the file manager, with a fallback to the normal archive opener for other .zip files.
Element.animate() to animate single elements with given keyframes
Animate HTML elements with Element.animate() from the Web Animations API; control timing, playback state, and completion without extra libraries.
SASS: Adding, removing and converting units
Sass unit arithmetic makes it easy to attach, strip, and convert measurement units when working with CSS values and timing data.
When loading Yaml contents in Ruby, use the :freeze argument to deep-freeze everything
YAML.safe_load and YAML.safe_load_file can deep-freeze parsed YAML with freeze: true, keeping configuration data fully immutable; ... .freeze leaves nested objects mutable.
Creating a self-signed certificate for local HTTPS development
Local HTTPS development often needs a trusted certificate for browser access. Self-signed or CA-signed certificates let localhost or wildcard hostnames run without warning dialogs.
How to search through logs on staging or production environments
Finding a request in staging or production logs often requires searching several servers and archived files; grep or zgrep can query current and zipped logs.
How to make your application assets cachable in Rails
Rails asset URLs need fingerprints or timestamps to let browsers cache images, stylesheets, and scripts long-term without serving stale files after updates.
How to let passenger restart after deployment with capistrano
Phusion Passenger restart handling after deploy is version-dependent; capistrano-passenger picks the correct restart command automatically and hooks into Capistrano.
Maintaining custom application tasks in Rails
Large Rails projects benefit from keeping application tasks slim, separating the executable wrapper from the business code, and testing both rake tasks and scripts.
Unpoly 3.7.1, 3.7.2 and 3.7.3 released
Bug fixes for Unpoly 3.7.1–3.7.3 address lost form input, validation race conditions, autosubmit regressions, and fragment targeting issues in complex asynchronous flows.
CSS: Letting text flow around a round element
Wrap text around a circular element by floating it and using shape-outside with content-box; matching shape-margin to the element margin keeps spacing consistent.
Cucumber step to match table rows with Capybara
Cucumber step for checking table rows in Capybara, with optional exact matching, row order control, wildcards, and support for colspan or rowspan tables.
Pitfall: ActiveRecord callbacks: Method call with multiple conditions
Conditional after_save callbacks can silently lose earlier :if conditions when the same method is registered twice. Combine predicates or move the logic into the callback.
Copying validation errors from one attribute to another
Virtual attributes can need validation messages shown on a different field, especially with Paperclip attachments and related file-name checks.
Rails: Using custom config files with the config_for method
Global Rails settings can live in YAML files with environment-specific overrides via config_for, avoiding constant collisions and supporting fetch or bang accessors.
Dockerfile and Heredocs
BuildKit heredocs make Dockerfile multiline commands easier to read, but compatibility with older clients and unclear command chaining limit practical use.
Browser debugging tricks
Useful browser devtools techniques for finding tricky JavaScript bugs, inspecting calls, and pausing execution on changes to state, URLs, or DOM properties.
RubyMine: Real-time Collaborating in the IDE
Collaborative coding in RubyMine lets others join your editor for pairing, review, or shared terminal access, with permissions from read-only to full access.
Ignore commits when git blaming
git blame output can be noisy after formatting or mass-renaming commits. --ignore-revs-file keeps selected revisions out of blame and can be enabled per project.
You should probably load your JavaScript with <script defer>
Loading JavaScript with defer avoids blocking rendering, runs after parsing, and still before DOMContentLoaded, making it the safer default for head scripts.
How to: Context-dependent word expansion in RubyMine
Context-dependent word completion in RubyMine speeds coding and reduces typos; Cyclic Expand Word can be remapped on German keyboards.
Disable PostgreSQL's Write-Ahead Log to speed up tests
Unlogged PostgreSQL tables can speed up Rails test suites by skipping the write-ahead log, but they raise crash-related data loss risk and stay unsuitable for production.
RSpec: be_true does not actually check if a value is true
be_true matches any truthy value, not only true; be_false likewise checks for falsiness. Use exact equality with == or eq when boolean values must be verified.