views:

107

answers:

1

Hi,

I'm using the amazon-product-advertising-api gem and am following the example code to try and grab music album data.

The code I have is as follows:

post '/mash' do
    username = params[:username]

    user = Scrobbler::User.new(username)

    @recommendations = user.recommendations

    @urls = { }
    @recommendations.each do |t|
        lookup = AmazonProductAdvertisingApi::Operations::Item::ItemSearch.new(t.name, search_index = "Music", region = :uk)
        lookup.run

        if lookup.is_valid
            title = lookup.response.items.first.item_attributes.title
            url = lookup.response.items.first.detail_page_url
            @urls[title] = url
        end
    end 

    haml :results
end

However, I receive the following error:

NoMethodError at /mash
undefined method `item_attributes' for nil:NilClass

When I do put lookup.response.items.first I get the following error/output:

TypeError at /mash
#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1b80e38 @item_links=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1b80d34 @contained_elements=[#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1b7eca0 @description="Add To Wishlist", @contained_elements=[], @url="http://www.amazon.co.uk/gp/registry/wishlist/add-item.html%3Fasin.0%3DB001J66K1M%26SubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB001J66K1M"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1b7ec14 @description="Tell A Friend", @contained_elements=[], @url="http://www.amazon.co.uk/gp/pdp/taf/B001J66K1M%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB001J66K1M"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1b7eb60 @description="All Customer Reviews", @contained_elements=[], @url="http://www.amazon.co.uk/review/product/B001J66K1M%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB001J66K1M"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1b7eaac @description="All Offers", @contained_elements=[], @url="http://www.amazon.co.uk/gp/offer-listing/B001J66K1M%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB001J66K1M"&gt;]&gt;, @detail_page_url="http://www.amazon.co.uk/Idle-Forest-Chit-Chat-Kinny/dp/B001J66K1M%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB001J66K1M", @contained_elements=[], @item_attributes=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1b7f81c @artist="Kinny", @manufacturer="Tru Thoughts", @title="Idle Forest of Chit Chat", @product_group="Music", @contained_elements=[]>, @asin="B001J66K1M">

Which I assumed meant there is data there which I can access.

The full put lookup.response.items shows:

TypeError at /mash
#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a8e4e4 @contained_elements=[#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a8cf68 @item_links=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a8ce64 @contained_elements=[#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a8add0 @description="Add To Wishlist", @contained_elements=[], @url="http://www.amazon.co.uk/gp/registry/wishlist/add-item.html%3Fasin.0%3DB001J66K1M%26SubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB001J66K1M"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a8ad44 @description="Tell A Friend", @contained_elements=[], @url="http://www.amazon.co.uk/gp/pdp/taf/B001J66K1M%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB001J66K1M"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a8ac90 @description="All Customer Reviews", @contained_elements=[], @url="http://www.amazon.co.uk/review/product/B001J66K1M%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB001J66K1M"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a8abdc @description="All Offers", @contained_elements=[], @url="http://www.amazon.co.uk/gp/offer-listing/B001J66K1M%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB001J66K1M"&gt;]&gt;, @detail_page_url="http://www.amazon.co.uk/Idle-Forest-Chit-Chat-Kinny/dp/B001J66K1M%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB001J66K1M", @contained_elements=[], @item_attributes=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a8b94c @artist="Kinny", @manufacturer="Tru Thoughts", @title="Idle Forest of Chit Chat", @product_group="Music", @contained_elements=[]>, @asin="B001J66K1M">, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a86dac @item_links=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a86ca8 @contained_elements=[#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a84c14 @description="Add To Wishlist", @contained_elements=[], @url="http://www.amazon.co.uk/gp/registry/wishlist/add-item.html%3Fasin.0%3DB0008G2FZO%26SubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB0008G2FZO"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a84b88 @description="Tell A Friend", @contained_elements=[], @url="http://www.amazon.co.uk/gp/pdp/taf/B0008G2FZO%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB0008G2FZO"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a84ad4 @description="All Customer Reviews", @contained_elements=[], @url="http://www.amazon.co.uk/review/product/B0008G2FZO%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB0008G2FZO"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a84a20 @description="All Offers", @contained_elements=[], @url="http://www.amazon.co.uk/gp/offer-listing/B0008G2FZO%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB0008G2FZO"&gt;]&gt;, @detail_page_url="http://www.amazon.co.uk/Forgetting-Remember-Kinny-Horne/dp/B0008G2FZO%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB0008G2FZO", @contained_elements=[], @item_attributes=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a85790 @artist="Kinny &amp; Horne", @manufacturer="Tru Thoughts", @title="Forgetting to Remember", @product_group="Music", @contained_elements=[]>, @asin="B0008G2FZO">, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a80bf0 @item_links=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a80aec @contained_elements=[#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a7ea58 @description="Add To Wishlist", @contained_elements=[], @url="http://www.amazon.co.uk/gp/registry/wishlist/add-item.html%3Fasin.0%3DB000AMY0O0%26SubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000AMY0O0"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a7e9cc @description="Tell A Friend", @contained_elements=[], @url="http://www.amazon.co.uk/gp/pdp/taf/B000AMY0O0%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000AMY0O0"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a7e918 @description="All Customer Reviews", @contained_elements=[], @url="http://www.amazon.co.uk/review/product/B000AMY0O0%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000AMY0O0"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a7e864 @description="All Offers", @contained_elements=[], @url="http://www.amazon.co.uk/gp/offer-listing/B000AMY0O0%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000AMY0O0"&gt;]&gt;, @detail_page_url="http://www.amazon.co.uk/Us-Fire-VINYL-Kinny-Horne/dp/B000AMY0O0%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB000AMY0O0", @contained_elements=[], @item_attributes=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a7f5d4 @artist="Kinny &amp; Horne", @manufacturer="Tru Thoughts", @title="Us on Fire [12\" VINYL]", @product_group="Music", @contained_elements=[]>, @asin="B000AMY0O0">, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a7aa34 @item_links=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a7a930 @contained_elements=[#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a7889c @description="Add To Wishlist", @contained_elements=[], @url="http://www.amazon.co.uk/gp/registry/wishlist/add-item.html%3Fasin.0%3DB0008G2FZ4%26SubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB0008G2FZ4"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a78810 @description="Tell A Friend", @contained_elements=[], @url="http://www.amazon.co.uk/gp/pdp/taf/B0008G2FZ4%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB0008G2FZ4"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a7875c @description="All Customer Reviews", @contained_elements=[], @url="http://www.amazon.co.uk/review/product/B0008G2FZ4%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB0008G2FZ4"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a786a8 @description="All Offers", @contained_elements=[], @url="http://www.amazon.co.uk/gp/offer-listing/B0008G2FZ4%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB0008G2FZ4"&gt;]&gt;, @detail_page_url="http://www.amazon.co.uk/Why-Me-VINYL-Kinny-Horne/dp/B0008G2FZ4%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB0008G2FZ4", @contained_elements=[], @item_attributes=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a79418 @artist="Kinny &amp; Horne", @manufacturer="Tru Thoughts", @title="Why Me [7\" VINYL]", @product_group="Music", @contained_elements=[]>, @asin="B0008G2FZ4">, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a74878 @item_links=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a74774 @contained_elements=[#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a726e0 @description="Add To Wishlist", @contained_elements=[], @url="http://www.amazon.co.uk/gp/registry/wishlist/add-item.html%3Fasin.0%3DB001J66K1C%26SubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB001J66K1C"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a72654 @description="Tell A Friend", @contained_elements=[], @url="http://www.amazon.co.uk/gp/pdp/taf/B001J66K1C%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB001J66K1C"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a725a0 @description="All Customer Reviews", @contained_elements=[], @url="http://www.amazon.co.uk/review/product/B001J66K1C%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB001J66K1C"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a724ec @description="All Offers", @contained_elements=[], @url="http://www.amazon.co.uk/gp/offer-listing/B001J66K1C%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB001J66K1C"&gt;]&gt;, @detail_page_url="http://www.amazon.co.uk/Enough-Said-7-VINYL-Kinny/dp/B001J66K1C%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB001J66K1C", @contained_elements=[], @item_attributes=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a7325c @artist="Kinny", @manufacturer="Tru Thoughts", @title="Enough Said [7\" VINYL]", @product_group="Music", @contained_elements=[]>, @asin="B001J66K1C">, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a6e6bc @item_links=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a6e5b8 @contained_elements=[#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a6c524 @description="Add To Wishlist", @contained_elements=[], @url="http://www.amazon.co.uk/gp/registry/wishlist/add-item.html%3Fasin.0%3DB0008G2G0I%26SubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB0008G2G0I"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a6c498 @description="Tell A Friend", @contained_elements=[], @url="http://www.amazon.co.uk/gp/pdp/taf/B0008G2G0I%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB0008G2G0I"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a6c3e4 @description="All Customer Reviews", @contained_elements=[], @url="http://www.amazon.co.uk/review/product/B0008G2G0I%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB0008G2G0I"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a6c330 @description="All Offers", @contained_elements=[], @url="http://www.amazon.co.uk/gp/offer-listing/B0008G2G0I%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB0008G2G0I"&gt;]&gt;, @detail_page_url="http://www.amazon.co.uk/Forgetting-Remember-VINYL-Kinny-Horne/dp/B0008G2G0I%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB0008G2G0I", @contained_elements=[], @item_attributes=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a6d0a0 @artist="Kinny &amp; Horne", @manufacturer="Tru Thoughts", @title="Forgetting to Remember [VINYL]", @product_group="Music", @contained_elements=[]>, @asin="B0008G2G0I">, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a68500 @item_links=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a683fc @contained_elements=[#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a66368 @description="Add To Wishlist", @contained_elements=[], @url="http://www.amazon.co.uk/gp/registry/wishlist/add-item.html%3Fasin.0%3DB000N0LE0W%26SubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000N0LE0W"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a662dc @description="Tell A Friend", @contained_elements=[], @url="http://www.amazon.co.uk/gp/pdp/taf/B000N0LE0W%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000N0LE0W"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a66228 @description="All Customer Reviews", @contained_elements=[], @url="http://www.amazon.co.uk/review/product/B000N0LE0W%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000N0LE0W"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a66174 @description="All Offers", @contained_elements=[], @url="http://www.amazon.co.uk/gp/offer-listing/B000N0LE0W%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000N0LE0W"&gt;]&gt;, @detail_page_url="http://www.amazon.co.uk/Forgetting-Remember-Kinny-Horne/dp/B000N0LE0W%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB000N0LE0W", @contained_elements=[], @item_attributes=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a66ee4 @artist="Kinny &amp; Horne", @manufacturer="Tru Thoughts", @title="Forgetting to Remember", @product_group="Music", @contained_elements=[]>, @asin="B000N0LE0W">, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a62344 @item_links=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a62240 @contained_elements=[#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a601ac @description="Add To Wishlist", @contained_elements=[], @url="http://www.amazon.co.uk/gp/registry/wishlist/add-item.html%3Fasin.0%3DB000CAEYEQ%26SubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000CAEYEQ"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a60120 @description="Tell A Friend", @contained_elements=[], @url="http://www.amazon.co.uk/gp/pdp/taf/B000CAEYEQ%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000CAEYEQ"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a6006c @description="All Customer Reviews", @contained_elements=[], @url="http://www.amazon.co.uk/review/product/B000CAEYEQ%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000CAEYEQ"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a5ffb8 @description="All Offers", @contained_elements=[], @url="http://www.amazon.co.uk/gp/offer-listing/B000CAEYEQ%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000CAEYEQ"&gt;]&gt;, @detail_page_url="http://www.amazon.co.uk/Rod-Kinny-EP/dp/B000CAEYEQ%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB000CAEYEQ", @contained_elements=[], @item_attributes=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a60d28 @artist="Rod Kinny", @manufacturer="Import (Megaphon Importservice)", @title="The Rod Kinny EP", @product_group="Music", @contained_elements=[]>, @asin="B000CAEYEQ">, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a5c188 @item_links=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a5c084 @contained_elements=[#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a59ff0 @description="Add To Wishlist", @contained_elements=[], @url="http://www.amazon.co.uk/gp/registry/wishlist/add-item.html%3Fasin.0%3DB000E9X33I%26SubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000E9X33I"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a59f64 @description="Tell A Friend", @contained_elements=[], @url="http://www.amazon.co.uk/gp/pdp/taf/B000E9X33I%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000E9X33I"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a59eb0 @description="All Customer Reviews", @contained_elements=[], @url="http://www.amazon.co.uk/review/product/B000E9X33I%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000E9X33I"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a59dfc @description="All Offers", @contained_elements=[], @url="http://www.amazon.co.uk/gp/offer-listing/B000E9X33I%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000E9X33I"&gt;]&gt;, @detail_page_url="http://www.amazon.co.uk/Us-Fire-VINYL-Kinny-Horne/dp/B000E9X33I%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB000E9X33I", @contained_elements=[], @item_attributes=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a5ab6c @artist="Kinny &amp; Horne", @manufacturer="Tru Thoughts", @title="Us on Fire [12\" VINYL]", @product_group="Music", @contained_elements=[]>, @asin="B000E9X33I">, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a55fcc @item_links=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1a55ec8 @contained_elements=[#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1af7034 @description="Add To Wishlist", @contained_elements=[], @url="http://www.amazon.co.uk/gp/registry/wishlist/add-item.html%3Fasin.0%3DB000CA74KM%26SubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000CA74KM"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1af9adc @description="Tell A Friend", @contained_elements=[], @url="http://www.amazon.co.uk/gp/pdp/taf/B000CA74KM%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000CA74KM"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1afd358 @description="All Customer Reviews", @contained_elements=[], @url="http://www.amazon.co.uk/review/product/B000CA74KM%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000CA74KM"&gt;, #<AmazonProductAdvertisingApi::Operations::Base::Element:0x1b00918 @description="All Offers", @contained_elements=[], @url="http://www.amazon.co.uk/gp/offer-listing/B000CA74KM%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB000CA74KM"&gt;]&gt;, @detail_page_url="http://www.amazon.co.uk/Open-Up-the-Letter/dp/B000CA74KM%3FSubscriptionId%3D1V38YK4WRF7GKYKXBSR2%26tag%3Dwhishapo-21%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB000CA74KM", @contained_elements=[], @item_attributes=#<AmazonProductAdvertisingApi::Operations::Base::Element:0x1abe9c8 @manufacturer="Simon Kinny-Lewis", @title="Open Up the Letter", @product_group="Music", @contained_elements=[]>, @asin="B000CA74KM">]>

If I try and put title I get the following error:

ArgumentError at /mash
tried to create Proc object without a block

Where as raise title seems to know what is going on:

RuntimeError at /mash
Idle Forest of Chit Chat

The same thing happens if put/raise url (though obviously with the URL not the title).

Unfortunately my Ruby knowledge is in the stage of learn as I go and I have no idea what is happening right now. Any help would be greatly appreciated.

(Also in case it helps, this is part of a Sinatra application...)

Cheers

+1  A: 

it looks to me that your "lookup.response.items.first." is returning a nil object, so you need to validate first that there is at least one item for your lookup

Joe_GI
Surely the fact that when I 'put' it and get an about that suggests that it is an object? Or does ruby not work like that?
Adam Taylor