J'utilise Rails pour un moteur de blog. J'implémente une fonction d'archivage qui est basée sur des mois et des années uniques où un article a été publié.Sélection de dates distinctes pour une archive de blog
est ici la fonction de concombre:
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
J'ai du mal à comprendre la meilleure approche pour cela. Dois-je aller hardcore avec une requête SQL et si oui, comment cela ressemblerait-il? (En utilisant PostgreSQL)
Ou y a-t-il une façon de le faire en douceur en utilisant simplement Rails pur?
l'aide d'une requête SQL serait " hardcore "? – araqnid