我想向不是今天生日的其他人发送通知邮件。我已经使用代码找出今天过生日的人......
控制器代码:
@people = Person.find(:all, :conditions => ["DAY(date) = ? AND MONTH(date) = ?", Date.today.day, Date.today.month])
现在,我如何修改它以获取生日人以外的人?
我想向不是今天生日的其他人发送通知邮件。我已经使用代码找出今天过生日的人......
控制器代码:
@people = Person.find(:all, :conditions => ["DAY(date) = ? AND MONTH(date) = ?", Date.today.day, Date.today.month])
现在,我如何修改它以获取生日人以外的人?
@people = Person.where('DAY(date) <> ? OR MONTH(date) <> ?', Date.today.day, Date.today.month)
当然应该是:
@people = Person.where('DAY(date) <> ? AND MONTH(date) <> ?', Date.today.day, Date.today.month)
使用 OR 它将排除今天当天的其他月份和当前月份的其他日期的人。
@people = Person.where("extract(month from date) != ? AND extract(day from date) != ?", Date.today.month, Date.today.day)