daniel
daniel

Reputation: 3115

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

Upvotes: 2

Views: 2298

Answers (1)

Dylan Markow
Dylan Markow

Reputation: 124419

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)

Upvotes: 9

Related Questions