Tag Archives: Rails

Rails Gotcha: ActiveRecord Caches Associated Records by Default

ActiveRecord will cache the results of association method calls by default, unless you tell it not to. (This applies to Rails 2.3.2 and perhaps earlier versions.) From the documentation: project.milestones # fetches milestones from the database project.milestones.size # uses the … Continue reading

Share
Posted in Rails | Tagged , , , , | 2 Comments

Quick Hits: Setting the User Agent Header in Webrat

If you’ve read the new PragProg beta e-book on RSpec, you may have read that you can set HTTP headers for your Webrat request like so: Given /^I am browsing the site using Safari$/ do header "User-Agent" , "Mozilla/5.0 (Macintosh; … Continue reading

Share
Posted in Rails, ruby, Testing | Tagged , , , , | 1 Comment

Better Rails Searching with Named Scopes using Scope Builder

When it comes writing elegant search code in a Rails app, Named Scopes immediately come to mind.  And for good reason: they’re a fantastic way to express, well, scopes, for your searches.  In your Person model, you might have named … Continue reading

Share
Posted in Rails | Tagged , , | Leave a comment

Quick and Dirty Messaging

Our Rails Rumble 2008 entry, Great Minds (you can have a look at the latest version or the original Rumble version), required a messaging system. Such systems are easy to do wrong, and we knew we’d need something that would … Continue reading

Share
Posted in Great Minds, Javascript, Programming, Rails | Tagged , , , , , , , , , , | 3 Comments