views:

62

answers:

3

Hi, I am trying to get all users that are updated maximum 90 seconds ago:

User.find(:all, :include => { :core => :image }, 
      :conditions => ["updated_at > ?", Time.now - 90.seconds] )

But it doesn't work.

why?

how can i do?

thanks

A: 

Do you need to specify users.updated_at

tsdbrown
i don't think so...
j.
A: 

If you set config.time_zone in your environment.rb to anything other than UTC, you need to do

User.find(:all, :include => { :core => :image }, 
      :conditions => ["updated_at > ?", Time.now.utc - 90.seconds] )

I'm going to assume that image is an attribute of an association called core?

Ben
That will also depend on ActiveRecord time zone setting, won't it?
Alex - Aotea Studios
@Alex Like I said, "If you set config.time_zone in your environment.rb to anything other than UTC..." That's the ActiveRecord setting.
Ben
A: 

It can be time zone problem. Try to find out Time.now - 1.day, if it'll work, so set your Time.zone in application controller.

And second, you can try your construction without :include option if it cause your problem

fl00r