Archive for October, 2008

Gem cache search depricated in boot.rb

October 23rd, 2008 | Category: Development,Rails

I was sick of getting the following deprication warning running rubygems version 1.3.0 and a rails 1.2.6 project.

“Gem::SourceIndex#search support for String patterns is deprecated
./script/../config/boot.rb:20 is outdated”

So I made some modifications to the boot.rb file so that it checks for the rails gem similar to the rails 2.x apps.  The gem itself is still loaded in the 1.2 fashoin.  Here is a diff on the changes

<       rails_gem ='rails', "=#{rails_gem_version}.0").sort_by { |g| g.version.version }.last
<       if rails_gem
<         gem "rails", "=#{rails_gem.version.version}"
<         require rails_gem.full_gem_path + '/lib/initializer'
<       else
<         STDERR.puts %(Cannot find gem for Rails =#{rails_gem_version}.0:
<     Install the missing gem with 'gem install -v=#{rails_gem_version} rails', or
<     change environment.rb to define RAILS_GEM_VERSION with your desired version.
<   )
>       begin
>         gem "rails", rails_gem_version
>         gem_dir ={|p|"#{p}/gems/rails-#{rails_gem_version}")}.first
>         require "#{gem_dir}/gems/rails-#{rails_gem_version}/lib/initializer"
>       rescue Gem::LoadError => load_error
>         $stderr.puts %(Missing the Rails #{rails_gem_version} gem. Please `gem install -v=#{rails_gem_version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)

Hope this helps with those annoying warnings.

1 comment

VIM tricks: comment block of code

October 16th, 2008 | Category: Development,Linux

A friend of mine (Shovan) was asking how to comment out a block of code using VIM. This can easily be done using the “Visual Block” feature of VIM. To enter visual block mode use “Ctrl + v”. At this point you can use “j” or “k” to highlight the lines in which you want to comment out. Then use “Shift + i” to enter insert mode. Type the respective comment character (# for ruby and bash, // for php), then hit “Esc” to exit insert mode.

No comments

Generate a Rails version specific project

October 09th, 2008 | Category: Development,Rails

If you have rails 2.x installed but need to generate a rails 1.x project, you can use the version tag as follows:

rails _1.2.6_ project

Just replace the 1.2.6 with whatever version you need, and make sure you use underscores before and after the version.

No comments