我正在使用Rails作爲博客引擎。我正在實施歸檔功能,該功能基於已發佈帖子的唯一月份和年份進行歸檔。爲博客文檔選擇不同的日期
這裏的黃瓜功能:
Scenario: Displaying an archive menu from distinct posts months and years
Given the following posts exists for the blog "Blondinbella":
| Title | Published at |
| Redbull | 1 March 2010 11:00 |
| Tuesday outfit | 2 January 2010 11:00 |
| Monday outfit | 1 January 2010 11:00 |
| Another outfit | 1 December 2009 11:00 |
When I visit the blog "Blondinbella"
Then I should see "March 2010" in the archive menu
And I should see "January 2010" in the archive menu
And I should see "December 2009" in the archive menu
But I should not see "February 2010" in the archive menu
我有一個很難搞清楚這樣做的最好的辦法。我應該用SQL查詢去核心嗎?如果是這樣的話,看起來如何? (使用PostgreSQL)
或者有沒有一種方法可以順利地使用純Rails?
使用SQL查詢將是「鐵桿「? – araqnid 2010-12-12 21:59:02