Updated for Rails 4. Scopes now using lambda blocks.