RI For Your Ruby Gems

June 23rd, 2006

Ruby comes with a great utilty called RI for searching and displaying ruby documentation. I have had varying levels of success in getting this to work with ruby gems so I wanted to share my findings so others may benefit from my trials and errors.

Attempt 1

The first tip I found for this (thanks to Brandt Lofton on the RadRails mailing list) involves modifying your site_ruby/1.8/rubygems/doc_manager.rb by changing this line

r.document(['--quiet', '--op', rdoc_dir]
+ @rdoc_args.flatten + source_dirs)

To:

r.document(['--quiet', '--op', '--merge', '-r', '--ri-system', rdoc_dir]
+ @rdoc_args.flatten + source_dirs)

You must then run the command:

gem rdoc --all

This will install all of your installed gems rdoc documentation for use by Ri.

NOTE: In my experience, this command must complete or the documentation will not be installed properly. For instance, in InstantRails1.3a, the camping-unabridged.rb file causes problems so I renamed it to camping-unabriged.rb-renamed so it will be skipped.

Attempt 2

Some people have experienced problems (myself included) with those steps above. So, I recently tried to find an alternative approach. I found this
post
by Eric Hodel, who implemented a different patch for ruby-core.

I tried following in his footsteps, but I was not successful. However, others seem to have gotten that one to work, so you may have better luck than I did.

Attempt 3

If all else fails, they say the third time is the charm. If you can’t get either of those methods to work, there is one more thing you can do to manually install your gem documentation.

This should work for any ruby code you have. Just change directories to the root of the code you want to be able to search with Ri and run this command:

rdoc --ri-site

This will install your documentation into the share/site directory of your ruby install where Ri will be able to read it.

NOTE: I had problems trying to generate the docs for all of my ruby gems at once so you may want to just do this individually for the ones that matter the most, such as actionpack, activerecord etc.

It may seem like a lot of effort just to be able to see your gem documentation from within Ri, but from my personal experience it is completely worth it. Having the ability to instantly look up the Rails documentation has definitely flattened the learning curve for me with Rails as I instantly can see how stuff works, or what the name of that AJAX method is etc.

Enjoy!

Redirecting with Lighttpd

June 20th, 2006

I just recently changed my site to permanently redirect http://www.atomgiant.com and http://blog.atomgiant.com to just http://atomgiant.com so please make a note of it.

This will make it easier for me to track my site stats, but just as important, it will have a positive impact on search engine rankings.

There are many ways to perform this redirect such as via meta redirects, but I decided to use Lighttpd for two reasons:

  1. Lighttpd makes this really easy.
  2. The redirect is instantaneous. With meta redirects there can be a very noticeable delay.

My lighttpd redirect code is as follows:

$HTTP["host"] =~ "^(www.|blog.)" {
    url.redirect = (
        "^/(.*)" => "http://atomgiant.com/$1",
        "" => "http://atomgiant.com/",
        "/" => "http://atomgiant.com/"
    )
  }

Also, don’t forget to include mod_redirect as one of your lighttpd server.modules

References:
The redirect code was adopted from here

Free Application Icon Sets

June 12th, 2006

Looking for some free application icon sets? I had a hard time finding some good ones when I was first looking for some. Thankfully I happened across these two wonderful ones:

If you know of some good ones, let me know and I’ll add them to this list.

MySQL, Ruby and Windows

June 5th, 2006

Just over the last month or so I started noticing a growing number of MySQL errors when developing Ruby on Rails applications on Windows. The errors would usually say something like so:

Mysql::Error: Lost connection to MySQL server during query

I have seen these in the past and there were some substantial patches that fixed them in Rails core before the 1.0 release, but all of a sudden they are back again.

I think I may have finally found a solution thanks to a post on the rails mailing list.

Just follow the steps on this blog posting to update your MySQL/Ruby driver and you should be all set:

http://www.vandomburg.net/pages/mysql-ruby-windows

Before I dive into what that title means, a little background:

To provide full-text searching of gifts within the GiftHat.com, I am using a ruby gem called Ferret written by Dave Balmain.

Ferret is a port of the popular Java search engine called Lucene.

The Ferret library is excellent, but one thing it suffers from is poor Windows support due in large part to the lack of good support for Windows by ruby itself.

But it looks like that is about to change thanks to a new Apache project called Lucy. Lucy will be a direct port of the Java Lucene engine in pure C. This will provide a much more straight-forward way to integrate the Lucene searching functionality into non-Java languages such as ruby, perl, PHP and python.

This is excellent news thanks to Dave Balmain and Marvin Humphrey for making this happen.

For further reading on this news, read it straight from the source here