NetManiac

Witold Rugowski on web20 wave with Ruby on Rails

Including gems with new rubygems

Posted on April 23, 2007 - Filed Under Ruby, RubyOnRails

Have You seen something like this:


NameError (undefined local variable or method `acts_as_taggable' for Route:Class):

after You have upgraded to rubygems-0.9.2? Well I saw and did a little investigation. The results:

With new rubygems require_gem is replaced with gem command. One of the differences is that with gem autorequire feature is no longer enabled. In other words gem prepares LOAD_PATH with directory with gems code, but does not include gems code automagically. So with gem command including acts_as_taggable should look like this:

gem 'acts_as_taggable'
require 'taggable'

As You can see we need to specify directly file with gem code (but we don’t have know what path is needed). The question is what we need to include. Well, this information we can get from gem itself, using shell gem command (following block is shell CLI not Ruby code):

[viciu@bsd ~]$ gem spec acts_as_taggable| grep autoreq
autorequire: taggable

This way we know what we have to include to run gem.

Popularity: 5% [?]

Hits for this post: 4447

Similar Posts

Comments

One Response to “Including gems with new rubygems”

  1. Brian McQuay on June 19th, 2007 20:32

    Nice work. The whole tagging thing in Rails is whacky to me still. Which shall I use, the gem that everyone says is depricated, the plugin which I can\’t seem to find a decent api for, acts_as_taggable_on_steroids which has the same problem. I\’m working with the gem right now cause its the only one I found a decent api for.

Leave a Reply