Skip to content

Instantly share code, notes, and snippets.

@kellysutton
Created November 20, 2011 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellysutton/1380926 to your computer and use it in GitHub Desktop.
Save kellysutton/1380926 to your computer and use it in GitHub Desktop.
So fresh and so new (new)
class Array
def newest
records = self.select{ |e| e.kind_of? ActiveRecord::Base }
records.sort do |a, b|
a.created_at <=> b.created_at
end
records.last
end
def freshest
records = self.select{ |e| e.kind_of? ActiveRecord::Base }
records.sort do |a, b|
a.updated_at <=> b.updated_at
end
records.last
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment