我從flickr檢索個人的照片集(專輯)列表。我如何從這個散列數組中提取ID,然後使用flickr.photosets.getPhotos來列出每個相冊中的圖像?我仍然在學習Ruby,並且對此感到非常困惑。我很感激任何正確的方向。Ruby Flickr API和Photosets
當我嘗試將set.each do .. anything
添加到@photosets
塊 - 我得到一個沒有方法錯誤'each'。
photos_controller.rb
require 'flickraw'
class PhotosController < ApplicationController
def index
FlickRaw.api_key = ENV['FlickRaw_api_key']
FlickRaw.shared_secret = ENV['FlickRaw_shared_secret']
@photosets = flickr.photosets.getList(user_id: '[email protected]').each do |set|
set
end
end
end
照片/ index.html.erb
<h1>Listing photosets</h1>
<%= @photosets %>
電流輸出
清單photosest
{
"id" =>"72157633435549025",
"primary" =>"8720558709",
"secret" =>"d6f79d3d3c",
"server" =>"7395",
"farm" =>8,
"photos" =>"8",
"videos" =>0,
"title" =>"Poetry Project",
"description" =>"",
"needs_interstitial" =>0,
"visibility_can_see_set" =>1,
"count_views" =>"4",
"count_comments" =>"0",
"can_comment" =>0,
"date_create" =>"1368044794",
"date_update" =>"1368044886"
},
{
"id" =>"72157633308505122",
"primary" =>"8674031898",
"secret" =>"8cd5722def",
"server" =>"8543",
"farm" =>9,
"photos" =>"22",
"videos" =>0,
"title" =>"Photo Midterm",
"description" =>"",
"needs_interstitial" =>0,
"visibility_can_see_set" =>1,
"count_views" =>"2",
"count_comments" =>"0",
"can_comment" =>0,
"date_create" =>"1366676884",
"date_update" =>"1366943480"
}
這使得這麼多的意義,我......但我發現這個錯誤未定義的方法'[] ='for# –
latazzajones
2014-10-20 01:14:53
任何想法的代碼部分觸發它? 'getList'或'getPhoto'期間? – 2014-10-20 01:17:55
我在set [「photos」]後註釋掉了所有內容,並且沒有錯誤。 – latazzajones 2014-10-20 01:20:47