Skip to content

Instantly share code, notes, and snippets.

@pzaich
Created January 24, 2013 03:37
Show Gist options
  • Select an option

  • Save pzaich/4617430 to your computer and use it in GitHub Desktop.

Select an option

Save pzaich/4617430 to your computer and use it in GitHub Desktop.
opportunity for a anonymous block?
def under_minimum_order_size?(min = minimum_order_size, total = total_quantity_in_instance)
errors.add(:under_min, "Total quantity must be over #{min}") if total < min
end
def total_quantity_in_instance(total = 0)
self.custom_sizes.each do |custom_size|
total += custom_size.quantity.to_i
end
total
end
def minimum_order_size(min = 12)
min = 25 if self.custom_product.parent_product_type_name == "swim cap"
min
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment