---
title: "named_scope"
author: "bellstar"
date: "2008-12-05T13:09:14Z"
tags: []
slug: "named-scope"
draft: false
lastmod: "2008-12-05T13:16:24Z"
id: 287684
url: "https://bellstar.iteye.com/blog/287684"
---

```ruby

class Website < ActiveRecord::Base 
  named_scope :recent, lambda{ |limit|
    {:order => "created_at DESC",:limit => limit}
  }
end
Website.newest 3  #返回最新的三条记录

```