Automatically strip all string fields of an ActiveRecord
Trailing whitespace in string inputs causes duplicate-looking records and uniqueness bugs. A model trait strips leading and trailing spaces from :string fields before validation.
floere/phony
Formats and splits phone numbers worldwide, including many country-specific variations and edge cases, for normalization and consistent handling.
7 Ways to Decompose Fat ActiveRecord Models - Code Climate Blog
Fat ActiveRecord classes accumulate business logic over time, creating maintenance problems and callback hell in large apps. SRP keeps persistence objects focused and easier to change.
RSpec: Change the type of a spec regardless of the folder it lives in
Rails specs can get controller, model, or request helpers from directory-based inference; :type forces the desired context even when a file lives elsewhere.
jsTimezoneDetect
Determines a user's timezone in JavaScript when browser and system settings may be unreliable.
mattheworiordan/capybara-screenshot
Captures browser screenshots on demand or automatically when tests fail, making visual debugging of Capybara runs easier.
Fixing errors with state_machine when excluding states
StateMachine can raise undefined method '-' for #<StateMachine::BlacklistMatcher> when subtracting excluded states from all; use a union to build the allowed source states.
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.