Skip to content

Instantly share code, notes, and snippets.

@alindeman
Forked from fivetwentysix/gist:903486
Created April 5, 2011 12:21
Show Gist options
  • Save alindeman/903495 to your computer and use it in GitHub Desktop.
Save alindeman/903495 to your computer and use it in GitHub Desktop.
[47, 46, 45, ...].each do |i|
validates_numericality_of :"size_#{i}_quantity"
define_method :"size_#{i}_quantity" do
if self.variants.find_by_size(i)
self.variants.count_on_hand
else
0
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment