Undefined method `require_gem' for main:Object
To update an old app to Rails 2.x you will need to change 'require_gem' to just 'gem'.
Otherwise you will get: Undefined method `require_gem' for main:Object
About
Paul is a web developer for Kyanmedia web agency. He's lucky enough to write in Ruby on Rails full-time and uses this site to post snippets of code.
Contact
my name at gmail.com
More snippets
Take a look in the archive
Need a website?
Contact my employer. Make sure to check out our portfolio of work.
Hosting
I recommend hostingrails.com
8 comments made
I recently had this problem. I think the new version of rubygems use gem instead of require_gem. It’s not necessarily a Rails 2.x issue.
Actually, the new version of gems only requires a “require.” No gem or require_gem method needed. Just do this: require ‘rubygems’; require ‘yourlib’;
gem install—remote rake
I have been your problem before, and after i did it, it’s worked well.
Great. Thanks, all. I was stumbling blindly, then found this.
I had to use “gem” to get this to work:
!/usr/bin/env ruby
require ‘rubygems’ gem ‘multi’multi(:fib,0){1} multi(:fib,1){1} multi(:fib,Integer){|n|fib(n-1)+fib(n-2)}
puts fib(4)
sorry the formatting was messed up. I pasted the code on these to pastebins: http://code.bulix.org/ckqjv9-66832 http://www.pastebin.org/40737
I am new to RoR. After getting everything installed, I ran … rails sandbox
I received the error you reported. This is what fixed the issue for me … gem update rails
Thanks!!! Saved me a million!!
Got something to say?