如何从vendor / gem中的后台进程/控制台中请求gem

时间:2011-01-23 02:01:07

标签: ruby-on-rails gem

我在供应商/宝石中有一个gem unpacked(youtube_g),它可以在Rails加载时正常工作。

当我通过调用

运行delayed_job时,我需要使用这个gem
require 'youtube_g'

但我收到此错误::

MissingSourceFile: no such file to load -- youtube_g
    from /Users/t/.rvm/gems/ruby-1.9.1-p378/gems/activesupport-2.3.9/lib/active_support/dependencies.rb:182:in `require'
    from /Users/t/.rvm/gems/ruby-1.9.1-p378/gems/activesupport-2.3.9/lib/active_support/dependencies.rb:182:in `block in require'
    from /Users/t/.rvm/gems/ruby-1.9.1-p378/gems/activesupport-2.3.9/lib/active_support/dependencies.rb:547:in `new_constants_in'
    from /Users/t/.rvm/gems/ruby-1.9.1-p378/gems/activesupport-2.3.9/lib/active_support/dependencies.rb:182:in `require'
    from (irb):2
    from /Users/t/.rvm/rubies/ruby-1.9.1-p378/bin/irb:16:in `<main>'

我有什么想法可以解决这个问题?

1 个答案:

答案 0 :(得分:0)

Rails能够自动加载路径,因此gem可以在没有在gemfile中声明的情况下工作。

但是后台任务没有这个智慧,试着在你的gemfile中添加它:

gem 'youtube_g', :path => "vendor/proper_folder"