Ruby: How to grow or shrink an array to a given size

Posted About 9 years ago by Arne Hartherz.

If you want to grow a Ruby Array, you might find out about #fill but it is not really what...

Don't forget: Automatically remove join records on has_many :through associations

Posted About 9 years ago by Thomas Klemm.

# Given the following models class Image < ActiveRecord::Base has_many :album_images has_many :albums, through: :album_images

Using form models (aka decorators) with Devise

Posted About 9 years ago by Dominik Schöler.

To use a form model with devise, you can simply override #resource_class in a controller. A typical use case...

Fontawesome 4+ icon naming conventions

Posted About 9 years ago by Dominik Schöler.
yoyo.io

Fontawesome 4 has introduced new naming conventions that make it easy to retrieve variants of a given icon.

Rails 4 introduced collection_check_boxes

Posted About 9 years ago by Dominik Schöler.
edgeapi.rubyonrails.org

Starting from Rails 4.0, you can use a special form options helper called #collection_check_boxes. It behaves similar to...

Capybara: Waiting for pending AJAX requests after a test

Posted About 9 years ago by Henning Koch.

When ending a Selenium test Capybara resets the browser state by closing the tab, clearing cookies, localStorage, etc.

rspec_candy 0.4.0 released

Posted About 9 years ago by Henning Koch.

Now supports RSpec 3 and Rails 4 Drops support for state_machine, which has some issues with Rails 4 and...

Differences between transactions and locking

Posted About 9 years ago by Henning Koch.

Web applications can be used by multiple users at the same time. A typical application server like Passenger has multiple...

Verifying doubles in RSpec 3

Posted About 9 years ago by Henning Koch.
relishapp.com

RSpec 3 has verifying doubles. This breed of mock objects check that any methods being stubbed are present on an...

Communication between collaborating directives in Angular

Posted About 9 years ago by Henning Koch.
blog.carbonfive.com

What if a complicated component comes along that is naturally modeled by multiple directives? This group of directives, as a...

Versatile Cucumber step regarding hovering above elements

Posted About 9 years ago by Dominik Schöler.

Here's a pretty useful steps that hasn't made it into Spreewald yet. It is best used with the...

Slack integration for deployments via Capistrano

Posted About 9 years ago by Arne Hartherz.
github.com

You can hook into Slack when using Capistrano for deployment. The slackistrano gem does most of the heavy lifting for...

Use CSS sibling selectors instead :last-child (or :first-child)

Posted About 9 years ago by Arne Hartherz.
w3.org

Often times you want to give a bunch of elements the same style, except for the last. For example borders...

Ruby: Removing leading whitespace from HEREDOCs

Posted About 9 years ago by Henning Koch.

If you're on Ruby 2.3+ there's a <<~ operator to automatically unindent HEREDOCs: str = <<~MESSAGE Hello Universe!

Detecting when fonts are loaded via JavaScript

Posted About 9 years ago by Arne Hartherz.
patrickmarabeas.github.io

Webfonts are not always available when your JavaScript runs on first page load. Since fonts may affect element sizes, you...

Sharing cookies across subdomains with Rails 3

Posted About 9 years ago.

To achieve this goal you have to setup the session store like the following example: MyApp::Application.config.session_store( :cookie_store...

How to create giant memory leaks in AngularJS (and other client-side JavaScript)

Posted About 9 years ago by Henning Koch.

This guide shows how to create an AngularJS application that consumes more and more memory until, eventually, the browser process...

grosser/rspec-instafail

Posted About 9 years ago by Henning Koch.
github.com

Gem to show failing specs instantly. Unlike the --fail-fast option it doesn't abort abort on the first failure...

Block formatting contexts

Posted About 9 years ago by Dominik Schöler.

TL;DR Block formatting contexts establish an isolating container. float and clear only apply to elements within such a container...

Understanding z-index: it's about stacking contexts

Posted About 9 years ago by Dominik Schöler.

The CSS property z-index is not as global as you might think. Actually, it is scoped to a so...

RSpec: How to get a full backtrace

Posted About 9 years ago by Thomas Klemm.

Git: How to get a useful diff when renaming files

Posted About 9 years ago by Thomas Klemm.

tldr; Use git diff -M or git diff --find-renames when you've moved a few files around. Usage

How to load an SQL dump from a migration

Posted About 9 years ago by Henning Koch.

If you want to load an SQL dump from an ActiveRecord migration, you might find this to be harder than...

RSpec: Only stub a method when a particular argument is passed

Posted Over 9 years ago by Henning Koch.
relishapp.com

To only stub a method call if a given argument is used, but use the default implementation for other arguments...