app/models/line_item.rb in trollied-0.1.3 vs app/models/line_item.rb in trollied-0.1.4

- old
+ new

@@ -9,10 +9,11 @@ # this is deprecated in Rails 3x, find workaround # an observer seemed like overkill and would have 3x compatibility stuff todo anyway after_destroy { |record| record.order.line_item_destroyed } # needs to be unique to orders that are current (but not unique to orders generally) - # validates_uniqueness_of :order_id, :scope => [:purchasable_item_type, :purchasable_item_id] + validates_uniqueness_of :order_id, :scope => [:purchasable_item_type, :purchasable_item_id] + def validate errors.add(:order, I18n.t('line_item.already_in_order')) if !order.current? && !order.in_process? && order.contains?(purchasable_item) end end