Created
December 20, 2010 00:08
-
-
Save fnhipster/747856 to your computer and use it in GitHub Desktop.
Get next record while it exists.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def some_method | |
self.find(:all, :order => "position DESC").each do |obj| | |
next_obj = self.find(:first, :conditions => ["position > ?", obj.position], :order => "position DESC") | |
# ... | |
break if next_obj == self.last | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment