Forum: Ruby on Rails with_scope going protected.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C728d93eb5205cf20cac0c2928b0ad62?d=identicon&s=25 RJ (Guest)
on 2007-04-25 19: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,
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
This topic is locked and can not be replied to.