This project is archived and is in readonly mode.
default scope not changing when class is unloaded and reloaded
-
Prem Sichanugrist (sikachu)
- State changed from new to resolved
- Importance changed from to Low
Hi,
On the current
master, it seems like this issue has been fixed.# Foo.rb class Foo < ActiveRecord::Base puts "Loading Foo" default_scope where("id < 10") end# Rails console Loading development environment (Rails 3.1.0.beta) irb(main):001:0> Foo.count Loading Foo SQL (0.1ms) SELECT COUNT(*) FROM "foos" WHERE (id < 10) => 0Change the default scope
# Foo.rb class Foo < ActiveRecord::Base puts "Loading Foo" default_scope where("id > 5") end# Rails console irb(main):002:0> reload! Reloading... => true irb(main):003:0> Foo.count Loading Foo SQL (0.2ms) SELECT COUNT(*) FROM "foos" WHERE (id > 5) => 0 irb(main):004:0> -
Andrew White
Yes, it was fixed by the commits on #5497 Default scope and class reloading - though looking at this it needs backporting to 2-3-stable as well.