rails/turbolinks

Speeds up navigation by keeping the page alive between link clicks, avoiding repeated JavaScript and CSS recompilation while replacing the body and title.

Literally 101 Ruby tricks

Ruby has several lesser-known tricks for embedding data after __END__, interpolating special variables, and creating repeating sequences with cycle.

How Ruby lets you keep script and data in *one* file

Ruby's __END__ keyword can embed data after code in one file, and the DATA object reads that trailing content as a file.

Creating a Grid for Product View for a eCommerce Site

Responsive product grids make eCommerce catalogs easier to scan and fit different screen sizes without awkward wrapping or cramped layouts.

Rspec_spinner or cucumber_spinner get into an infinite loop

mathn can make rspec_spinner and cucumber_spinner loop forever while rendering the progress bar.

Workaround for broken integer division after requiring the mathn library

mathn can silently replace integer division with exact rationals across a Ruby project. A workaround limits the monkey patch to code that explicitly needs exact division.

An easy demonstration of what Twitter Bootstrap does

Bootstrap’s UI components and layout tools become easier to grasp through a simple demo with screenshots and source code.

A jQuery plugin pattern every jQuery plugin should use

jQuery plugins often need a consistent architecture to stay customizable and extensible. A standard plugin pattern helps avoid rigid, hard-to-maintain implementations.

Get rid of WARNING: Nokogiri was built against LibXML version 2.7.7, but has dynamically loaded 2.7.8

Nokogiri can warn when it was built against one LibXML version but loads another, often after upgrades or mismatched gems. Rebuilding or reinstalling the gem usually resolves it.

Howto transfer a single mysql table between several deployment stages

Copy a single MySQL table between deployment stages by dumping it from one database and importing it into another; imports overwrite existing tables, not merge them.

Asset pipeline may break Javascript for IE (but only on production)

JavaScript can break in Internet Explorer only after Rails asset compression in staging or production. Switching from UglifyJS to YUI Compressor can avoid these failures.

Cucumber step to interact with an iframe using Capybara webdriver

Capybara Cucumber steps can target a named iframe by switching Selenium into the frame, letting actions and assertions run inside embedded content.

Machinist blueprints do not work with a column :display

display conflicts with a reserved Machinist blueprint name, so a blueprint attribute using that label may fail unexpectedly.

Unsaved record disappears when assigning to an association

A belongs_to association can return nil after assigning a new record when the association is declared incorrectly. Using the symbol form belongs_to :avatar avoids the disappearing unsaved record.

exception_notification: Send exception mails in models

ExceptionNotifier.notify_exception sends failure emails from model code by handing it an exception object; older versions used ExceptionNotifier::Notifier.background_exception_notification.

Git: How to look at the stash

Viewing saved Git changes without applying them helps inspect unfinished work and compare older stashed revisions with git stash show, tig, or gitg.

Migrating to Spreewald

Migrating an existing cucumber test suite to Spreewald reduces custom step definitions by replacing web, email, shared, and table steps with built-in support.

How to not leave trailing whitespace (using your editor or Git)

Trailing whitespace causes noisy diffs and avoidable commit failures; editors or Git hooks can remove it automatically or block commits with git diff --check.

Using before(:context) / before(:all) in RSpec will cause you lots of trouble unless you know what you are doing

before(:context) in RSpec runs once outside transactions and can leak data between examples; before(:example) keeps specs isolated and safer.

Paperclip: undefined method `to_file' for #<Paperclip::Attachment:0000> (NoMethodError)

Paperclip 3.0.1 removed to_file, breaking code that reads attachment storage through File; Paperclip.io_adapters.for(file).read is the replacement.

Git basics: checkout vs. reset

git checkout and git reset both move pointers, but one restores files or switches branches while the other rewinds the current branch state.

CSS Animations Media Queries

CSS transitions make responsive sites feel smoother and more polished with minimal effort.

ActionMailer sometimes breaks e-mails with multiple recipients in Rails 2

Rails 2 mail sending can produce malformed headers for multiple recipients because a buggy TMail version inserts a blank line. A maintained fork fixes the issue when no MTA repairs it.

How to convert an OpenStruct to a Hash

Convert OpenStruct instances to a hash with to_h; older Ruby versions use marshal_dump to access the underlying data.