Ruby-on-rails – Overriding a Rails default_scope

ruby-on-rails

If I have an ActiveRecord::Base model with a default-scope:

class Foo < ActiveRecord::Base

  default_scope :conditions => ["bar = ?",bar]

end

Is there any way to do a Foo.find without using the default_scope conditions? In other words, can you override a default scope?

I would have thought that using 'default' in the name would suggest that it was overridable, otherwise it would be called something like global_scope, right?

Best Answer

In Rails 3:

foos = Foo.unscoped.where(:baz => baz)