Skip to content

Instantly share code, notes, and snippets.

@geoffreyd
Created February 16, 2009 09:29
Show Gist options
  • Save geoffreyd/65090 to your computer and use it in GitHub Desktop.
Save geoffreyd/65090 to your computer and use it in GitHub Desktop.
def self.first_uninteresting
last = 0
Number.all(:order => "number").each do |n| # Number.find/all will return an enumerable, so you can each it directly.
return last + 1 if n.number.to_i != last + 1 # if's can be on the same line at the end for basic tests
last = n.number.to_i #ops forgot the number casting
end
last + 1 # Ruby will automatically return the last valuation, no need for 'return'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment