Skip to content

Instantly share code, notes, and snippets.

@vpereira
Created September 3, 2012 13:11
Show Gist options
  • Save vpereira/3609246 to your computer and use it in GitHub Desktop.
Save vpereira/3609246 to your computer and use it in GitHub Desktop.
class Foo
include Mongoid::Document
field :enabled, :type=>Boolean, :default=>false
scope :on, where(:enabled=>true)
scope :off, where(:enabled=>false)
end
irb> Foo.on.count
0
irb> Foo.off.count
100
irb> Foo.off.limit(10).update_all(:enabled=>true)
irb> Foo.on.count
100
irb> Foo.off.count
0
Expected: Foo.on.limit => 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment