无法在我的控制器中初始化youtube_it



我想建立一个应用程序,我可以在YouTube上搜索视频。似乎最受欢迎的选择是youtube_it gem。

我将gem添加到我的Gemfile中,并运行bundle install。当我执行bundle query --local时,我可以看到gem是预设的(版本2.1.4)。

所以,根据README,我似乎应该在我的控制器(?)做这样的事情:

class ConsoleController < ApplicationController  
  .
  .
  .
  def search
    require 'youtube_it'
    client = YouTubeIt::Client.new(:dev_key => "my developer key")
  end
end

但是我得到"cannot load such file——youtube_it"错误

如果我删除require函数,我得到"未初始化的常量ConsoleController::YouTubeIt"错误。

有人知道我在这里做错了什么吗?

更新:

/Gemfile.lock

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (4.0.3)
      actionpack (= 4.0.3)
      mail (~> 2.5.4)
    actionpack (4.0.3)
      activesupport (= 4.0.3)
      builder (~> 3.1.0)
      erubis (~> 2.7.0)
      rack (~> 1.5.2)
      rack-test (~> 0.6.2)
    activemodel (4.0.3)
      activesupport (= 4.0.3)
      builder (~> 3.1.0)
    activerecord (4.0.3)
      activemodel (= 4.0.3)
      activerecord-deprecated_finders (~> 1.0.2)
      activesupport (= 4.0.3)
      arel (~> 4.0.0)
    activerecord-deprecated_finders (1.0.3)
    activesupport (4.0.3)
      i18n (~> 0.6, >= 0.6.4)
      minitest (~> 4.2)
      multi_json (~> 1.3)
      thread_safe (~> 0.1)
      tzinfo (~> 0.3.37)
    addressable (2.3.6)
    arel (4.0.2)
    bcrypt (3.1.7)
    bootstrap-sass (3.1.1.1)
      sass (~> 3.2)
    builder (3.1.4)
    capybara (2.2.1)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      xpath (~> 2.0)
    coderay (1.1.0)
    coffee-rails (4.0.1)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.7.0)
    devise (3.2.4)
      bcrypt (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 3.2.6, < 5)
      thread_safe (~> 0.1)
      warden (~> 1.2.3)
    diff-lcs (1.2.5)
    erubis (2.7.0)
    execjs (2.0.2)
    factory_girl (4.2.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (4.2.1)
      factory_girl (~> 4.2.0)
      railties (>= 3.0.0)
    haml (4.0.5)
      tilt
    haml-rails (0.5.3)
      actionpack (>= 4.0.1)
      activesupport (>= 4.0.1)
      haml (>= 3.1, < 5.0)
      railties (>= 4.0.1)
    hike (1.2.3)
    i18n (0.6.9)
    jbuilder (1.5.3)
      activesupport (>= 3.0.0)
      multi_json (>= 1.2.0)
    jquery-rails (3.1.0)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    json (1.8.1)
    launchy (2.4.2)
      addressable (~> 2.3)
    mail (2.5.4)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    method_source (0.8.2)
    mime-types (1.25.1)
    mini_portile (0.5.3)
    minitest (4.7.5)
    multi_json (1.9.3)
    nokogiri (1.6.1)
      mini_portile (~> 0.5.0)
    orm_adapter (0.5.0)
    pg (0.17.1)
    polyglot (0.3.4)
    pry (0.9.12.6)
      coderay (~> 1.0)
      method_source (~> 0.8)
      slop (~> 3.4)
    pry-rails (0.3.2)
      pry (>= 0.9.10)
    rack (1.5.2)
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (4.0.3)
      actionmailer (= 4.0.3)
      actionpack (= 4.0.3)
      activerecord (= 4.0.3)
      activesupport (= 4.0.3)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.0.3)
      sprockets-rails (~> 2.0.0)
    railties (4.0.3)
      actionpack (= 4.0.3)
      activesupport (= 4.0.3)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (10.3.1)
    rdoc (4.1.1)
      json (~> 1.4)
    rspec-core (2.14.8)
    rspec-expectations (2.14.5)
      diff-lcs (>= 1.1.3, < 2.0)
    rspec-mocks (2.14.6)
    rspec-rails (2.14.2)
      actionpack (>= 3.0)
      activemodel (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec-core (~> 2.14.0)
      rspec-expectations (~> 2.14.0)
      rspec-mocks (~> 2.14.0)
    sass (3.2.19)
    sass-rails (4.0.3)
      railties (>= 4.0.0, < 5.0)
      sass (~> 3.2.0)
      sprockets (~> 2.8, <= 2.11.0)
      sprockets-rails (~> 2.0)
    sdoc (0.4.0)
      json (~> 1.8)
      rdoc (~> 4.0, < 5.0)
    slop (3.5.0)
    sprockets (2.11.0)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sprockets-rails (2.0.1)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (~> 2.8)
    thor (0.19.1)
    thread_safe (0.3.3)
    tilt (1.4.1)
    treetop (1.4.15)
      polyglot
      polyglot (>= 0.3.1)
    turbolinks (2.2.2)
      coffee-rails
    tzinfo (0.3.39)
    uglifier (2.5.0)
      execjs (>= 0.3.0)
      json (>= 1.8.0)
    warden (1.2.3)
      rack (>= 1.0)
    xpath (2.0.0)
      nokogiri (~> 1.3)
PLATFORMS
  ruby
DEPENDENCIES
  bootstrap-sass (~> 3.1.1)
  capybara
  coffee-rails (~> 4.0.0)
  devise
  factory_girl_rails (~> 4.2.1)
  haml-rails
  jbuilder (~> 1.2)
  jquery-rails
  launchy (~> 2.4.2)
  pg
  pry-rails
  rails (= 4.0.3)
  rspec-rails
  sass-rails (~> 4.0.0)
  sdoc
  turbolinks
  uglifier (>= 1.3.0)

似乎youtube_it gem还没有安装。仔细检查gem 'youtube_it'是否包含在Gemfile中,并运行bundle update

或者你也可以删除Gemfile.lock,然后运行bundle install

相关内容

  • 没有找到相关文章

最新更新