Forum: Ruby on Rails with_scope going protected.

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
RJ (Guest)
on 2007-04-25 21:11
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 topic is locked and can not be replied to.