Yourub 的 NameError(未初始化常量)Gem

NameError (uninitialized constant) with Yourub Gem

当我使用 Yourub gem 配置搜索 youtube 视频时,服务器控制台 returns 向我显示以下错误消息:

Completed 500 Internal Server Error in 7ms

NameError (uninitialized constant ExploreController::Yourub):
  app/controllers/explore_controller.rb:18:in `search'

在 explore_controller 文件中我们可以找到:

class ExploreController < ApplicationController
  def index
    ...
  end
  def search
    if params[:queryType] == "users"
      ...
    elsif params[:queryType] == "tracks"
      client = Yourub::Client.new
      client.search(query: params[:queryField]) do |v|
        puts v
      end
      return redirect_to('/explore')
    else
      return redirect_to('/explore')
    end
  end
end

Also added my yourub.yml file here:

yourub_defaults: &yourub_defaults
  developer_key: 'apiKey'
  youtube_api_service_name: 'youtube'
  youtube_api_version: 'v3'
  application_name: "apiAplicationName"
  application_version: "0.1"
  log_level: WARN

development:
  <<: *yourub_defaults

production:
  <<: *yourub_defaults

test:
  <<: *yourub_defaults

重新启动 服务器。这应该可以解决问题。