Skip to content

Instantly share code, notes, and snippets.

@thanhcuong1990
Created July 20, 2014 14:49
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/2de3617bd657ac065e43 to your computer and use it in GitHub Desktop.
Save thanhcuong1990/2de3617bd657ac065e43 to your computer and use it in GitHub Desktop.
Scope examples
# /app/controllers/posts_controller.rb
def index
@posts = Post.find(
:all,
:conditions => {:user_id => current_user.id}, :order => 'created_at desc',
:limit => 10
)
@trending = Topic.find(
 :all,
:conditions => ["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