-
-
Save kuinak/767407a7b637abe4437d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment