Is there anyway to perform a query from within a validate function?
I need to verify that the sum of several rows does not exceed a certain
class Entry < ActiveRecord::Base
def validate totalhours = hours samedayentries = self.find_by_day_id(day_id) samedayentries.each do |i| totalhours += i[:hours] unless (id ==
errors.add_to_base( “You cannot enter more than 24 hours
in a day.”) if totalhours > 24
Or some better way to accomplish the same general idea. (I can do it in
the controller, but it really belongs in the model IMHO.)