Pluralise birthdays_controller.
This commit is contained in:
parent
6217b988c8
commit
b33d0dc673
2 changed files with 15 additions and 0 deletions
15
app/controllers/birthdays_controller.rb
Normal file
15
app/controllers/birthdays_controller.rb
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue