当我使用Yourub gem配置搜索youtube视频搜索时,服务器控制台会返回以下错误消息:
Completed 500 Internal Server Error in 7ms
NameError (uninitialized constant ExploreController::Yourub):
app/controllers/explore_controller.rb:18:in `search'
config/yourub.yml
https://msdn.microsoft.com/en-us/library/system.identitymodel.tokens.securitytokenhandler.validatetoken(v=vs.110).aspx 在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
此处还添加了我的yourub.yml文件:
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
答案 0 :(得分:1)
重新启动服务器。这应该可以解决问题。