我正在使用 Feedzirra 并尝试按发布日期对提要数据的哈希进行排序。我没有收到错误或任何东西,它只是没有排序。这是我的控制器中的代码:
class ClassifiedsController < ApplicationController
def index
require 'feedzirra'
feed_urls = ["http://newjersey.craigslist.org/jjj/index.rss", "http://cnj.craigslist.org/jjj/index.rss"]
feeds = Feedzirra::Feed.fetch_and_parse(feed_urls)
x = 1
@items = Hash.new
feeds.each do |feed_url, feed|
feed.entries.each do |entry|
@items[x] = {:title => entry.title, :url => entry.url,
:published => entry.published.to_i}
x = x + 1
end
end
@items.sort_by { |k, v| v[:published] }
end
end
任何帮助将不胜感激。谢谢!