search for: find_by_day_id

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

Did you mean: find_by_an_id
2006 Jan 12
0
Multi Row validation... or running queries within Validate function?
...om 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 end end Or some better...