Adding Thor Commands to Rails

Rails provides a nice documented way of adding Rake tasks to your engine, however sometimes you may want a command line operation that requires sophisticated interaction with the user, which can be tedious in Rake. Thor, is a great Ruby library designed for this purpose and its already built into Rails. In this post I'll go over how to create Thor commands and make them available through the rails command. If you're unfamiliar with Thor, take a look at the introduction, here to get up to speed.

Saving My Photo Library From Picturelife Using Chrome and Ruby

In this post I show you how I figured out how to save my photo library from the quickly deteriorating Picturelife service using Ruby and Chrome.

Modules, Roles, Mixins, and *ables in Ruby

Prerequisites

  • Blocks
  • Modules
  • Difference between including and extending Modules
  • Difference between instance and class methods

Demonstration

One of the most common problems that seem to naturally arise in code is handling objects that share a role. This tends to be an issue that is not immediately apparent, but as the application grows it begins to present itself. Let's illustrate this with a concrete example taken from the code used in this blog. A lot of this code will be ActiveRecord syntax, but the underlying concepts can be applied to plain old Ruby objects as well.