Created
July 20, 2014 16:05
-
-
Save thanhcuong1990/5801aee3ce52baaa7e4f to your computer and use it in GitHub Desktop.
Scope examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /app/models/topic.rb | |
class Topic < ActiveRecord::Base | |
scope :trending, lambda { |num| 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