Skip to content

Instantly share code, notes, and snippets.

@jbmyid
Last active August 29, 2015 14:05
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 jbmyid/ba6697e4ed0b03ed158b to your computer and use it in GitHub Desktop.
Save jbmyid/ba6697e4ed0b03ed158b to your computer and use it in GitHub Desktop.
class City < ActiveRecord::Base
def self.top_cities(order_by)
@top_cities ||= Hash.new do |h, key|
h[key] = where(top_city: true).order(key).to_a
end
@top_cities[order_by]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment