Skip to content

Instantly share code, notes, and snippets.

@thanhcuong1990
Last active January 11, 2016 19:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thanhcuong1990/9b62d32c563327874feb to your computer and use it in GitHub Desktop.
Save thanhcuong1990/9b62d32c563327874feb to your computer and use it in GitHub Desktop.
Scope examples
# /app/controllers/posts_controller.rb
def index
@posts = Post.where(:user_id => current_user.id).
order('created_at desc').
limit(10)
@trending = Topic.where('started_trending > ?', 1.day.ago).
order('mentions desc').
limit(7)
# ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment