Skip to content

Instantly share code, notes, and snippets.

@thanhcuong1990
Created July 20, 2014 16: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 thanhcuong1990/d04e76c8cffac4be9d17 to your computer and use it in GitHub Desktop.
Save thanhcuong1990/d04e76c8cffac4be9d17 to your computer and use it in GitHub Desktop.
Scope examples
# /app/models/topic.rb
class Topic < ActiveRecord::Base
scope :trending, lambda { |num = nil| where('started_trending > ?', 1.day.ago).
order('mentions desc').
limit(num) }
# ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment