From 0d15b6a5a634107d23584a6d8bfdf1f1d3725b10 Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Sun, 12 Jun 2011 00:12:48 -0400 Subject: [PATCH] arel sql syntax --- Gemfile | 1 + Gemfile.lock | 3 +++ app/models/tweet.rb | 8 +++----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index dcf4075..5d2c7db 100644 --- a/Gemfile +++ b/Gemfile @@ -14,6 +14,7 @@ gem 'haml', '3.1.2' gem 'rdoc', '2.4.3' gem 'erubis' gem 'rails_xss' +gem 'fake_arel' group :test do gem 'factory_girl' diff --git a/Gemfile.lock b/Gemfile.lock index a1a0dc5..961f143 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,6 +15,8 @@ GEM crack (0.1.8) erubis (2.7.0) factory_girl (1.3.3) + fake_arel (0.9.9) + activerecord (>= 2.3.5) faraday (0.6.1) addressable (~> 2.2.4) multipart-post (~> 1.1.0) @@ -63,6 +65,7 @@ DEPENDENCIES crack (= 0.1.8) erubis factory_girl + fake_arel haml (= 3.1.2) httparty (~> 0.7.8) mash (= 0.1.1) diff --git a/app/models/tweet.rb b/app/models/tweet.rb index 82f648a..048214c 100644 --- a/app/models/tweet.rb +++ b/app/models/tweet.rb @@ -23,13 +23,11 @@ def build_by_value(username, value) validates_uniqueness_of :status_id + named_scope :recent_first, ('status_at desc') + #TODO: Re tagless: should we even store entries w/o a tag? #TODO: maybe we shouldn't even store the from user in tweet - named_scope :recent, :order => 'status_at desc', :limit => 5, - :include => :tweet_tags, - :conditions => {:tagless => false} - - named_scope :recent_first, :order => 'status_at desc' + named_scope :recent, where(:tagless => false).includes(:tweet_tags).order('status_at desc').limit(5) class << self # Find the latest (most recent) Twitter status ID that we've fetched.