Uncategorized 28 Oct 2005 06:54 am
Using Gems that your host doesn’t have installed
There are a couple of reasons that you may want to do this. One is to be master of your universe. I really like this and will be moving Clubrs to use that.
You may also find a gem that your web host doesn’t have installed. You can ask them to install it, and they might, but you can also use it without their intervention. Here’s all you have to do:
- Install the Gem on your own system
- Open a command window in [RAILS_HOME]/vendor
- Type ‘gem unpack gem_name’ to expand the gem
-
UPDATE: Use the path to the lib folder in your require, e.g.:
require ‘units/lib/units’
That’s it. Now your app will have access to the gem as normal. Also, if there’s an installed version of the gem, your app will use your expanded gem rather than the installed gem.
The Rails team put in a nice, related feature with the 1.0 release candidates. There’s a Rake target to ‘freeze’ rails to a particular version:
rake freeze_rails
That will give you all the core Rails gems unpacked to
vendor/rails
To reverse you can use
rake unfreeze_rails
Which simply deletes the /vender/rails directory.