Skip to content

Instantly share code, notes, and snippets.

@huttneab
Last active August 29, 2015 13:57
Show Gist options
  • Save huttneab/9817775 to your computer and use it in GitHub Desktop.
Save huttneab/9817775 to your computer and use it in GitHub Desktop.
class City < ActiveRecord::Base
scope :city_roulette, to_a
scope :find_cities, ->(timezone) {where(timezone:timezone)}
end
@linqiu
Copy link

linqiu commented Mar 27, 2014

scope :random_city, -> {
  offset = rand(self.count)
  self[offset]
}  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment