我是ruby和nanoc的新手。我試圖根據時間對文章進行分類。所以我在我的博客上得到更準確的結果。根據時間排序文章,並沒有在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方法?
感謝
更新:我已經擁有它在耙文件啓動。所以我認爲我的耙文件在這裏很好。
time1 = Time.new
@time = time1.inspect
啊,對。但現在我刪除了。我得到一個錯誤 'ArgumentError:NilClass與時間比較失敗' – user1758162
然後我猜測一些文章的':time'屬性是零。 – ddfreyne
我明白了。解析一個新的時間對象並基於此對物品進行排序。謝謝。 如果你有時間。你能幫我回答這個 - http://stackoverflow.com/questions/13866141/how-to-generate-pages-for-each-tag-in-nanoc 謝謝:) – user1758162