how to properly create a between clause on mongo mapper

32 Views Asked by At

I'm trying to create a query like this

 User.find_each(created_at: [1.day.ago.utc, Date.now]) do |user|

but that didn't worked. Always return 0 users, but I do have users created in the 1 day timeframe. I believe I'm doing this query wrong, but the mongo mapper documentation says nothing about this. Any ideas?

1

There are 1 best solutions below

0
Maxime Beugnet On
  • Activate the profiling with db.setProfilingLevel(2).
  • Rerun your code.
  • Get the query you sent to MongoDB in the system.profile collection.
  • Run this query in the mongoshell to check what's wrong.
  • Update your code to send the command you want.