Not sure these are any better than your brute force, but...
> 1) Ensure that newly created slots dont overlap any existing ones for a
> particular team.
In your model define a ''before_save'' method that queries the
database to
find any slots that overlap the one you are trying to insert and if you
find them, return false which will cause the save to fail.
> 2) Quickly retrieve the ''current'' slot given a Team and
Time.now.
Slot.find(:first,
:conditions => ["? BETWEEN start_on AND end_on AND team_id = ?",
Time.now, Team.id])
>
> I can figure out how to do these two operations with a bit of grunting
> and sweaty brute force, but I''m wondering if anyone with a bit
more
> ActiveRecord-fu can help me out with any shortcuts to something more
> beautiful. :-)
>
> Any help appreciated.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---