Skip to content

Instantly share code, notes, and snippets.

@huttneab
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save huttneab/9817775 to your computer and use it in GitHub Desktop.

Select an option

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

linqiu commented Mar 27, 2014

Copy link
Copy Markdown
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