Ruby Cheatsheet

Debugging ruby code with bundler open

bundler open GEM-NAME

This will open up the source code of the gem installed using the editor set by the environment variables EDITOR or BUNDLER_EDITOR

You can set breakpoints, change the source code, grep through it with your editor.

Once debugging is finished run bundler pristine to reset any changes

Placeholder String Trick

Ruby has a trick for creating placeholders within a string and then populating the placeholders’ positions with an array of values.

VERSE = "On the %s day of Christmas my true love gave to me: %s."

VERSE % ["first", "a Partridge in a pair tree"]

The % inserts the array of values sequentially into the %s portions of the text

ruby, cheatsheet