arrow_backward Back to blog

with_scope is protected

I’ve seen a lot of people run into trouble using with_scope on edge.

The solution? Don’t use it or use it sparingly. They made it protected for a reason – to protect people from abusing it – but if you absolutely must have at it then you can do something like this:

 

So say you want to scope your finders to retrieve only MyModel objects of type ‘super’:

 

Using self.class.send is a way to get around public and private checking in ruby 1.8. Use with caution.

arrow_backBack

New Project Request