Created
May 25, 2009 18:24
-
-
Save tadman/117653 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 self.each(key_column = :id, &block) | |
connection.select_values("SELECT `#{key_column}` FROM `#{table_name}`").each do |key| | |
begin | |
yield(find(key)) | |
rescue ActiveRecord::RecordNotFound | |
# Ignore records which may have been deleted between the time the | |
# list is created and the record is fetched. | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment