lifo/docrails — comment on commit 745b7a14377607c5fddb8cd1151d69267095242c
File:  line 0
By mchung:

Here's my controller's `feed` method:

def feed
@blog_posts = BlogPost.live.order('published_at DESC').limit(10)
respond_to do |format|
format.atom
end
end

Using:

feed.updated(@blog_posts.first.published_at)

The SQL generated looks like this:

ActiveBlog::BlogPost Load (0.3ms) SELECT "active_blog_blog_posts".* FROM "active_blog_blog_posts" WHERE (published_at < '2011-11-26 20:49:46.864632' AND draft = 'f') ORDER BY published_at DESC LIMIT 1
ActiveBlog::BlogPost Load (0.5ms) SELECT "active_blog_blog_posts".* FROM "active_blog_blog_posts" WHERE (published_at < '2011-11-26 20:49:46.864632' AND draft = 'f') ORDER BY published_at DESC LIMIT 10

Using:

feed.updated(@blog_posts[0].published_at)

The SQL generated looks like this:

ActiveBlog::BlogPost Load (0.4ms) SELECT "active_blog_blog_posts".* FROM "active_blog_blog_posts" WHERE (published_at < '2011-11-26 20:50:17.316039' AND draft = 'f') ORDER BY published_at DESC LIMIT 10

I'm on rails-3.1.3, ruby-1.9.2-p290