search for: samedayentri

Displaying 1 result from an estimated 1 matches for "samedayentri".

Did you mean: samedayentries
2006 Jan 12
0
Multi Row validation... or running queries within Validate function?
...to perform a query from within a validate function? I need to verify that the sum of several rows does not exceed a certain value eg: class Entry < ActiveRecord::Base belongs_to :day belongs_to :project def validate totalhours = hours samedayentries = self.find_by_day_id(day_id) samedayentries.each do |i| totalhours += i[:hours] unless (id == i[:id]) end errors.add_to_base( "You cannot enter more than 24 hours in a day.") if totalhours > 24...