# How to embed with\_scope in ActiveRecord class defnition?

**URL:** <https://www.ruby-forum.com/t/how-to-embed-with-scope-in-activerecord-class-defnition/121668>\
**Category:** Rails\
**Created:** [November 29, 2007, 8:13pm UTC](https://www.ruby-forum.com/t/how-to-embed-with-scope-in-activerecord-class-defnition/121668 "2007-11-29T20:13:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@ssk](https://www.ruby-forum.com/u/ssk)\
**Post date:** [November 29, 2007, 8:13pm UTC](https://www.ruby-forum.com/t/how-to-embed-with-scope-in-activerecord-class-defnition/121668/1 "2007-11-29T20:13:18Z")

</div>

Hi,

I want to limit the scope of records for a ActiveRecord class.

class Product \< ActiveRecord::Base  
end

I can use with\_scope to limit the result set.  
However, I want to limit it in the model in a fixed way so that  
with\_scope rule is implicitly forced.

For example,

class Product \< ActiveRecord::Base  
with\_scope :find =\> {:conditions = “created\_at \> ‘2000-01-01’”}  
end

How can I accomplish that?

Thanks in advance.

Sam

---

<div class="post-metadata">

**Author:** ![ssk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@ssk](https://www.ruby-forum.com/u/ssk)\
**Post date:** [November 29, 2007, 8:16pm UTC](https://www.ruby-forum.com/t/how-to-embed-with-scope-in-activerecord-class-defnition/121668/2 "2007-11-29T20:16:33Z")

</div>

> **[\#5 Using with\_scope - RailsCasts](http://railscasts.com/episodes/5-using-with-scope)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

–  
James M.
