views:

28

answers:

0

I've got a group of messages in mongo which I am retrieving in rails with

@messages =  current_user.user_messages(@user)

I now want to select the number of messages which were created in the last week, so I thought I could take the @messages and query that directly with

@countRecent = @messages.count(:conditions => {:created_at =>{'$lt' => 7.days.ago}})

though I've also tried

@countScore = @messages.count(:conditions => ["created_at BETWEEN ? and ?", 0.days.ago, 7.days.ago])

based on the rails documenation.

If I just return @messages.count, i get the response of all messages, but if I try to filter by created_at, I get a response of 0.

Is it possible to query the returned objects in this way? or do i have to go back to the database with another query?