String#indent: Know your definitions!

Posted About 10 years ago by Dominik Schöler.

String#indent is not a standard Ruby method. When you use it, be sure to know where this method comes...

Finding a method name on a Ruby object

Posted About 10 years ago by Thomas Klemm.

Wondering how a specific method on an object is exactly named? You can use Enumerable#grep to detect it in...

How to call overwritten methods of parent classes in Backbone.js

Posted Over 10 years ago by Arne Hartherz.

When you are working with Backbone models and inheritance, at some point you want to overwrite inherited methods but call...

Ruby number formatting: only show decimals if there are any

Posted Over 10 years ago by Dominik Schöler.

Warning: Because of (unclear) rounding issues and missing decimal places (see examples below), do NOT use this when dealing with...

rbenv: How to switch to another Ruby version (temporarily, per project, or globally)

Posted Over 10 years ago by Arne Hartherz.

Unlike RVM, rbenv does not offer a command like rvm use. By default, it respects your project's .ruby-version...

krisleech/wisper

Posted Over 10 years ago by Henning Koch.
github.com

Publish/subscribe for Ruby classes. Bonus: You do not have to declare events before using them.

How to load only a subset of a massive MySQL dump

Posted Over 10 years ago by Arne Hartherz.

I had a huge MySQL dump that took forever (as in: days) to import, while I actually just wanted to...

Installing therubyracer and libv8 with Ruby 1.8 on OSX Mavericks

Posted Over 10 years ago by Dominik Schöler.
coderwall.com

There seems to be no way to use therubyracer -v '0.11.4' and libv8 -v '3.11.8.17' on OS X Mavericks.

How to install older versions of REE with rbenv on Ubuntu 12.04

Posted Over 10 years ago by Arne Hartherz.

Rbenv won't compile REE 2011.03 properly on Ubuntu 12.04, failing with an error in tcmalloc.cc. If you want to...

The new Modularity 2 syntax

Posted Over 10 years ago by Henning Koch.

We have released Modularity 2. It has many incompatible changes. See below for a script to migrate your applications automatically...

Opal, A new hope (for Ruby programmers)

Posted Over 10 years ago by Henning Koch.
confreaks.com

Opal is a source to source ruby to javascript compiler, corelib and a runtime implementation that currently passes 3000 rubyspecs...

Sort a Ruby array with multiple criteria

Posted Over 10 years ago by Henning Koch.

If you want to sort a Ruby array with a primary, secondary, etc. criterium, use a sort_by that contains...

How to fix "undefined method `name' for Array" error when running bundled commands on Ruby 1.8.7 + Rails 2.3

Posted Over 10 years ago by Arne Hartherz.

On recent/fresh installations of Ruby 1.8.7 you may encounter this error why calling any bundled binary (or just bundle exec...

Auto-coerced virtual attributes with Virtus

Posted Over 10 years ago by Henning Koch.

We've since created ActiveType which has a restricted subset of Virtus' features. It might be enough for your needs...

Careful when calling a Ruby block with an array

Posted Over 10 years ago by Henning Koch.

When a Ruby block or proc takes multiple parameters, and you call it with an Array, Ruby will unexpectedly splat...

Embed Font Awesome icons from your CSS

Posted Over 10 years ago by Henning Koch.

An annoying part of using font icons is that the icons usually need to live in the DOM. This is...

Ruby constant lookup: The good, the bad and the ugly

Posted Over 10 years ago by Henning Koch.

In Ruby, classes and modules are called constants. This card explains how Ruby resolves the meaning of a constant.

Ruby: How to measure code execution time in an IRB or Rails console

Posted Over 10 years ago by Dominik Schöler.

Paste this method into your console: def time(&block) puts Benchmark.measure(&block) end Now time { Some.lengthy_task } will behave similar...

Cancelling the ActiveRecord callback chain

Posted Over 10 years ago by Henning Koch.

What Rails version Within before_* Within after_* Cancel later callbacks Rails 1-4 return false return false Cancel later callbacks...

Ruby 1.8: SimpleDelegator is very slow

Posted Over 10 years ago by Tobias Kraze.

If you're still working on ruby 1.8, you should know that using SimpleDelegator is often prohibitively slow. I have...

How to subscribe to Ruby security updates

Posted Over 10 years ago by Henning Koch.

Ruby publishes security issues and MRI updates on ruby-lang.org. Unfortunately there is no straight-forward way to subscribe to these...

Fix „command failed: /usr/bin/wkhtmltopdf ...“ using PDFKit middleware

Posted Over 10 years ago.

Ubuntu 12.04 LTS x64, Ruby 1.8.7, Rails 2.13, PDFKit 0.5.4, Phusion Passenger Apache 2 I ran into this, when I...

Ruby: The & operator

Posted Over 10 years ago by Dominik Schöler.
ablogaboutcode.com

After reading, you will know why and how runners.each(&:run) works. Here some tidbits: & can be quite confusing because it...