if next_result %Q|<a href="/meals/#{next_result['key']}">#{next_result['key']}</a>| else "" end end

Aside from the method name and variable names seemingly tied to a year, there is nothing in there that is specific to years—except the to_i call on the years (won't work on "2009-05"). If I use strings instead, that helper ought to work just as well for ISO 8601 substrings (e.g. 2009-05). The above line, reworked for strings:

detect{|result| compare_years[result['key'], current.to_s]}

After running all of my specs and Cucumber scenarios to verify that the change had no effect on the underlying behavior, I add this to meals-by-month Haml template: