./script/../config/boot.rb:29: undefined method `gem' for main:Object (NoMethodError)

I am new to svn but have just created a repository on my server using
svnserve. I have done all the ignore *.log files and temp directory
stuff and have just tryed to generate my first controller useing
script/generate controller ManageProducts --svn and am getting the
error below

dodgyboz@shuttle:~/itsagoal/trunk$ ruby script/generate controller
ManageProductRange --svn

./script/../config/boot.rb:29: undefined method `gem' for main:Object
        from script/generate:2:in `require'
        from script/generate:2

Can anyone help me out with this little problem??

I have found the answer, or at least this has worked for me so i no
longer have a problem.

Sometimes gem needs a little reminder. Running "sudo gem update --
system" fixes the bug on ubuntu OS anyway

Came across this post while I was trying to fix a similar problem.
Your answer solved my problem as well. Thanks.