Q:

how to filter records on a date

Hey I am trying to find a way to get my post records filtered. I only want to display records that are not older than the day before yesterday. I come up with this line of code,
Post.where(:course_id => current_user.courses & :date > (Date.yesterday-1))

but I receive this error:  can't convert Symbol into Array
Thx for your time

A:

You can't use an ampersand between multiple hash items, and you must use strings to do any less-than, greater-than, etc.
Post.where("course_id in (?) and date > ?", current_user.courses, Date.yesterday - 1)

