ruby technical

Seeing with Ctags

Within all hackery, the road to mastery usually leads you to the nitty gritty low-level implementation details of what you are trying to grasp. Even though there are many books on advanced material, they only get you so far before you find that they are either no longer up-to-date or they don’t cover a particular edge case that is imperative for you.

To the source?! Uhh….

Despite the optimistic battle cry, reading the source code of a complex application/framework/language can be daunting, if not rather dry and immensely boring. Most of it isn’t intended to be read as a book and before you know it, you’re looking for the good parts. Just a specific portion that you’d like to understand instead of all that bloat in place to support stuff you don’t care about.


CTags to the rescue!

CTags will go through and create an index (or tag) file that allows you to search dynamically. I’m assuming that you’re using vim as your text editor – there are flavors for Emacs, etc. that may suite you better.



The easiest way is through homebrew.

brew install ctags


Suppose you’re interested in rails. Grab a copy of the source
git clone git://

Now you want to have ctags index those files but since vim will look for the tags file in the current directory and keep searching one level above, let’s run this command from the user home (or the root directory that contains all of your rails projects)

cd ctags -R ./path/to/rails/source

Add the following lines to your .vimrc file: filetype on set tags=tags;/

Use The Source, Luke!

Fire up a new shell and go over to any rails project. Over a rails method (for example, create_after), hit ctrl+] to see the definition in the source. You can toggle back to where you were before using ctrl+t. Pretty sweet, huh?

There are additional shortcuts to listing matches, etc. that you can see for ctags either through the man pages or online.

Blaze away and learn the underlying framework with ease, one method call at a time.

ruby technical

Rebuilding Rails

It has been a couple of years since I first dove into Ruby on Rails to build some side projects. However, there’s still an awful lot of magic going on with the framework.

With the release of Rails 4, there seems to be even more magic to make everything easier. Unfortunately, I’ve found myself in a tough spot whenever the magic ceases to work for whatever reason.

Look in to the source? Sure, but unless you’re very strong with your ruby, all the elegant, clever code isn’t exactly an easy read.

Turns out the creator of Thin, Marc-André Cournoyer has a class called Owning Rails that has you building “a mini version of rails from scratch”.

A pretty good deal for a little over $500, considering that you also get a copy of his book Create Your Own Programming Language (The starting point for CoffeeScript).

Unfortunately, the class seems to be limited and full, with a waiting list. I liked the idea of building a mini version of rails – luckily, someone else has a similar take on mastering rails.

Rebuilding Rails covers a similar challenge of building your own simpler framework on Rack to understand the internals of Rails. I went ahead and bought the book after going through the free first two chapters.

Understand Rails by Building a Ruby Web Framework

Gulp! Here’s to less magic!