开发者

Using gems in rails -- require 'gemname' results in No File Found

I've been trying to use the 'twitter_oauth' gem with my rails application but whenever I have require 'twitter_oauth', I get a "No such file to load" error.

I've already listed the twitter_oauth gem in my Gemfile, and when I try to initiate a new instance of Client in the rails console, it works perfectly fine, even when I don't first enter require 'twitter_oauth'. I even made a test ruby file where all it had was:

require 'twitter_oauth'

client = TwitterOAuth::Client.new
if client != nil
  puts "It worked!"
else
  puts "It did not work"
end

And running that file worked also.

I've tried putting require 'rubygems' also and I've tried placing the require 'twitter_oauth' code in the config/application.rb file.

Other gems work fine, such as 'will_paginate' (in my rails application, in rails console and in irb)

Also, interestingly enough, when I'm in irb, require 'twitter_oauth' results in an error too but when I run that simple ruby program, it wo开发者_高级运维rks fine.


I just installed this gem and made a new rails 3 app, added it to the Gemfile and I can access it fine from 'rails console' and from within the app when running 'rails server' and also from 'irb'. Are you sure you've typed the gem name correctly? I confused myself by typing 'twitter_oath' a few times and not 'twitter_oauth'...

Have you got the latest rubygems? perhaps try:

$ sudo gem install rubygems-update
$ sudo gem update --system
$ sudo gem update

Are you using rails 3? What OS & ruby are you using?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜