secret
Created

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
class Foo < ActiveRecord::Base
default_scope where(reviewed: true)
end
 
 
 
 
Loading development environment (Rails 3.2.8)
1.9.3-p194 :001 > Foo.unscoped.all.size
Foo Load (0.2ms) SELECT "foos".* FROM "foos"
=> 7
1.9.3-p194 :002 > Foo.first.destroy
Foo Load (0.2ms) SELECT "foos".* FROM "foos" WHERE "foos"."reviewed" = 't' LIMIT 1
(0.0ms) begin transaction
SQL (0.4ms) DELETE FROM "foos" WHERE "foos"."id" = ? [["id", 4]]
(2.1ms) commit transaction
=> #<Foo id: 4, reviewed: true, created_at: "2012-09-27 04:03:08", updated_at: "2012-09-27 04:03:08">
1.9.3-p194 :003 > Foo.unscoped.all.size
=> 7
 
 
 
Loading development environment (Rails 4.0.0.beta)
1.9.3p194 :001 > Foo.unscoped.all.size
DEPRECATION WARNING: Calling #default_scope without a block is deprecated. For example instead of `default_scope where(color: 'red')`, please use `default_scope { where(color: 'red') }`. (Alternatively you can just redefine self.default_scope.). (called from default_scope at /Users/ejp/.rvm/gems/ruby-1.9.3-p194@rails-4.0.0/bundler/gems/activerecord-deprecated_finders-fe150f26f009/lib/active_record/deprecated_finders/base.rb:57)
DEPRECATION WARNING: Relation#all is deprecated. If you want to eager-load a relation, you can call #load (e.g. `Post.where(published: true).load`). If you want to get an array of records from a relation, you can call #to_a (e.g. `Post.where(published: true).to_a`). (called from all at /Users/ejp/.rvm/gems/ruby-1.9.3-p194@rails-4.0.0/bundler/gems/activerecord-deprecated_finders-fe150f26f009/lib/active_record/deprecated_finders/relation.rb:163)
Foo Load (0.1ms) SELECT "foos".* FROM "foos"
=> 8
1.9.3p194 :002 > Foo.first.destroy
Foo Load (0.2ms) SELECT "foos".* FROM "foos" WHERE "foos"."reviewed" = 't' ORDER BY "foos"."id" ASC LIMIT 1
(0.1ms) begin transaction
SQL (0.5ms) DELETE FROM "foos" WHERE "foos"."id" = ? [["id", 3]]
(2.5ms) commit transaction
=> #<Foo id: 3, reviewed: true, created_at: "2012-09-27 04:19:44", updated_at: "2012-09-27 04:19:44">
1.9.3p194 :003 > Foo.unscoped.all.size
DEPRECATION WARNING: Relation#all is deprecated. If you want to eager-load a relation, you can call #load (e.g. `Post.where(published: true).load`). If you want to get an array of records from a relation, you can call #to_a (e.g. `Post.where(published: true).to_a`). (called from all at /Users/ejp/.rvm/gems/ruby-1.9.3-p194@rails-4.0.0/bundler/gems/activerecord-deprecated_finders-fe150f26f009/lib/active_record/deprecated_finders/relation.rb:163)
Foo Load (0.6ms) SELECT "foos".* FROM "foos"
=> 7

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.