0

我是 ruby​​ 和 nanoc 的新手。我正在尝试根据时间对文章进行排序。所以我在我的博客上得到了更准确的结果。

这就是我在我的sorted_articles_time.rb文件中使用的/helpers/

def sorted_articles_time
  articles.sort_by do |a|
    attribute_to_time(a[:time])
  end.reverse
end

但后来我得到了错误

NoMethodError: private method `sorted_articles_time' called for #<Nanoc::Site:0x007fd93b0a3f40>

我究竟做错了什么 ?有没有办法覆盖现有的 sorted_articles 方法?

谢谢

更新:我已经在 rake 文件中启动了它。所以我认为我的 rake 文件在这里很好。

time1 = Time.new
@time =  time1.inspect
4

2 回答 2

2

你在打电话@site.sorted_article_times吗?如果是这样,请离开该@site部分。助手旨在作为函数调用,而不是作为@site.

于 2012-12-12T21:34:33.263 回答
-3

使用模型中的 scrope。检查此活动的active_record_querying这是对您的文章进行排序的最佳位置。

于 2012-12-12T21:59:10.313 回答