28 Jul '12, 7am

It's a Blog - 07/27/12: ActiveRecord.count changes your select You can pass options to count eg count(distinct:true)

Chrome slow after click on body While investigating memory leaks in a single page JS app, we found that rendering times increased by ~2 seconds after clicking on the body of the document. It only happens in Chrome, Webkit and Firefox don't have the problem. We don't seem to have any click handlers that fire when clicking on the body. Putting .count on the end of an ActiveRecord query blows away your select Here's a scope for customers who have at least one subscription: Customer.select('DISTINCT customers.*').joins(:subscriptions).where("subscriptions.customer_id IS NOT NULL") This produces the following SQL: SELECT DISTINCT customers.* FROM "customers" INNER JOIN "subscriptions" ON "subscriptions"."customer_id" = "customers"."id" WHERE (subscriptions.customer_id IS NOT NULL) Say you want to know how many of these there are. If you put .count on the end of the scope, it co...

Full article: http://pivotallabs.com/users/kkelly/blog/articles/2214-07...

Tweets