2010-09-10 65 views
0

使用此itunes search寶石,並且文檔看起來非常簡單。它失敗 與iTunes搜索紅寶石:未初始化的常量Itunes

NameError: uninitialized constant Itunes

gem install itunes-search 

Usage 

base = Itunes::Base.new 

search_object = base.search("term"=>"The Killers") 

# get an array of the search_objects 

results = search_object.results 

results.each do |result| 
    puts result.trackViewUrl 
end 

puts result.attributes 

這裏是我的代碼

$ irb 
irb(main):001:0> require 'rubygems' 
=> true 
irb(main):002:0> require 'itunes-search' 
=> true 
irb(main):003:0> base = Itunes::Base.new 
NameError: uninitialized constant Itunes 
from (irb):3 

回答

4

的開發人員可能更改模塊名稱或書面的不正確的文件,你應該做的:

base = ItunesSearch::Base.new 

代替作者:

base = Itunes::Base.new 

因爲該模塊名稱爲ItunesSearch而不是Itunes。這應該工作:)

相關問題