# With\_scope going protected

**URL:** <https://www.ruby-forum.com/t/with-scope-going-protected/92925>\
**Category:** Rails\
**Created:** [April 25, 2007, 7:11pm UTC](https://www.ruby-forum.com/t/with-scope-going-protected/92925 "2007-04-25T19:11:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RJRJRJ](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8491ac/32.png) [@RJRJRJ](https://www.ruby-forum.com/u/RJRJRJ)\
**Post date:** [April 25, 2007, 7:11pm UTC](https://www.ruby-forum.com/t/with-scope-going-protected/92925/1 "2007-04-25T19:11:18Z")

</div>

Was reading up on with\_scope and came across this via err.the\_blog

> Deprecation is a step too far, there are legitimate uses of  
> with\_scope, particularly around encapsulated finds for permissions  
> models. I just think that there needs to be some serious warnings in  
> the documentation:

The decision has been rendered as follows: with\_scope will go protected  
from Rails 2.0. That means you’ll be able to use with\_scope in your own  
private finders (the only legitimate use I’ve seen), but not in, say,  
filters.

Now we just have to find a way to get those deprecation messages in  
there when its being called in the public space.

–

I am still rather a newbie so I am not 100% sure what the implications  
are. Does this mean that you will not be able to use (for example)

Model.with\_scope( :find =\> {conditions = “blah” } do  
Model.count  
end

In your controllers? One reason I do use them in controllers is that it  
allows me to add conditions based on things not accessible from the  
model (Such as a session variable).

For example

def foo  
if session[:bar] == blah  
result = “field \> 10”  
end  
end

Model.with\_scope( :find =\> {conditions = foo } do  
Model.count  
end

Since it is a total pain in the arse to get such data into models  
removing with\_scope from controllers would be a kick in the nuts (to mix  
metaphors).

Can anyone RubyGroupie shed some light on this?

thanks

RJ
