Reputation: 99
def index
@current_week = Post.where(:created_at => (Date.today - 7)..(Date.today))
end
@current_week.each do |post|
....
end
Rails return an empty array. I just want to select all the video created the current week. Do you see where I'm wrong ?
Thank you
Upvotes: 3
Views: 959
Reputation: 17834
Try at_beginning_of_week
to fetch records created in the current week
@current_week = Post.where("created_at >= ?", Date.today.at_beginning_of_week)
Hope that helps!
Upvotes: 6