checking events that are on tomorrow in rails?
HI
i would like to write a method that returns all the events that are on tomorrow or within the next 24 hours.
e.g
def tomorrows_events
@events = Event.will_occur_in next_24_hours
end
i have a datetime
for each event which is called so to get it it would be, @event.date_and_time
i have the search logic gem installed but don't know if it supports dates, i couldn't find anything on it.
what would be the best way to write it? is there something in s开发者_StackOverflowearch logic i can use?
thanks
Event.all(:conditions => { :date_and_time => (Time.now.tomorrow.beginning_of_day)..Time.now.tomorrow.end_of_day})
I wrote a plugin that'll help you do this: http://github.com/radar/by_star.
You'd use this command for it:
Event.tomorrow(Time.zone.now, :field => "date_and_time")
Then it will return only results for tomorrow.
精彩评论