Displaying 1 result from an estimated 1 matches for "quantity_requested".
2008 Apr 23
1
Validation dependent on unsaved parent
...n
end
class LineItem < ActiveRecord::Base
belongs_to :order
belongs_to :item
def parlevel
if self.order
Parlevel.find(:first, :conditions => {:location_id =>
self.order.location_id, :item_id => self.item_id})
else
nil
end
end
def validate
if self.quantity_requested
if self.parlevel
limit = self.parlevel.quantity
else
limit = 0
end
errors.add(:quantity_requested,"above maximum of " + limit.to_s)
if self.quantity_requested > limit
end
end
end
=============
The current result of this code in the limi...