With_scope going protected

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,

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

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”

Model.with_scope( :find => {conditions = foo } do

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

Can anyone RubyGroupie shed some light on this?



This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs