Hi Jeremy,

Alternatively:

  def self.by_published(time)
    scoped_by_published_at(time.beginning_of_day..time.end_of_day)
  end


(instead of Date.parse you need to use Time.zone.parse in your tests though)



Lawrence

> Ah yeah of course, sorry didn't read it properly.
> I really can't see why you would do an IN like that though.
>
> On Mon, Oct 19, 2009 at 2:01 PM, Lawrence Pit <[email protected] 
> <mailto:[email protected]>> wrote:
>
>
>     The doc is correct.
>
>     If you use hash conditions with a range having Time objects,
>     you're fine.
>
>     If you use it with array conditions however, then you're in trouble.
>
>
>
>     Lawrence
>
>
>>     Yeah I think that documentation might be old, since in my test I
>>     got >= and < not and sql IN when I used a range.
>>
>>     On Mon, Oct 19, 2009 at 1:37 PM, Lawrence Pit
>>     <[email protected] <mailto:[email protected]>> wrote:
>>
>>
>>         It's described here:
>>
>>         
>> http://guides.rubyonrails.org/active_record_querying.html#time-and-date-conditions
>>
>>
>>
>>         Lawrence
>>
>>
>>>>         Be wary of passing in a Time-based Range object to ActiveRecord's  
>>>>         conditions like that as I've seen behaviour where it will check 
>>>> for  
>>>>         every second of that range. It could have changed since I've 
>>>> looked  
>>>>         though.
>>>>             
>>>         There's been much discussion re. this on the list so far, with code 
>>>  
>>>         examples and all. Mind expanding on what exactly Jeremy should be 
>>> wary  
>>>         of? Code would be good?
>>>
>>>         -- tim
>>>           
>>
>>
>>
>>
>>
>
>
>
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to