Tag Archives: named_scope

Be careful how you count in Rails

I’ve just encountered this problem yet again effecting code I’m working though, so I thought I’d quickly blog about it.
Put basically if you call count on a relationship it will always make a db call to see how many there are even if the relationship has been populated.  If you use size or any? they [...]

Posted in Features, Miscellaneous | Also tagged , | 3 Comments

Performance optimisation through named_scope

I recently gave a presentation about using named_scopes to WellRailed and while it was still on my mind I thought that I’d cover named_scope in conjunction with some performance optimisation work I’ve been doing.
I used to use relationship extensions lots and it always irked me that I was putting business logic for a model, say [...]

Posted in Miscellaneous | Also tagged , , | Leave a comment
  •  

  • About Nahum Wild

    I'm a High Performance Website Consultant specialising in Ruby on Rails deployments. In this blog I cover common problems I've seen and provide insight on optimisation techniques.

  • Recommend Me

    Follow me on Twitter