Pluralise birthdays_controller.

This commit is contained in:
gchq 2011-06-03 21:24:45 +02:00
parent 6217b988c8
commit b33d0dc673
2 changed files with 15 additions and 0 deletions

View file

@ -0,0 +1,15 @@
class BirthdaysController < ApplicationController
def index
n = Date.today
e = Date.today + 7.days
# two cases here: now + 7days iis still the same month. or it's not.
if n.month == e.month
@birthdays = Contact.where("birth_month = ? AND birth_day <= ? AND birth_day >= ?",
e.month, e.day, n.day)
else
@birthdays = Contact.where("(birth_month = ? AND birth_day <= ?) OR (birth_month = ? AND birth_day >= ?)",
e.month, e.day, n.month, n.day)
end
end
end