【问题标题】:How to require a gem from background process/console that is in vendor/gem如何从供应商/宝石中的后台进程/控制台中要求宝石
【发布时间】:2011-01-23 23:23:32
【问题描述】:

我在 vendor/gems 中有一个解压的 gem (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>'

有什么办法可以解决这个问题吗?

【问题讨论】:

    标签: ruby-on-rails gem


    【解决方案1】:

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

    但后台任务可能没有这种智慧,请尝试将其添加到您的 gemfile 中:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-16
      • 2011-02-08
      • 2011-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-12
      • 1970-01-01
      相关资源
      最近更新 更多