How to unscope a query from a default_scope in Rails

If you have a default_scope in your model and you want to make an unscoped query on that table:

YourModel.unscoped.where(:prop1 => 'someValue')

won’t work, the default_scope still be applied.

You need to call the reload method after unscoped. Like this:

YourModel.unscoped.reload.where(:prop1 => 'someValue')

Tagged ,

Leave a comment