This project is archived and is in readonly mode.
reload! doesn't reload
-
Philipp Steinacher
- Tag set to development environment, console, reload!
It also doesn't work with Rails 3.0.3 and ruby-1.9.2-p136
-
William Denniss
I'm not sure if the version of ruby matters, but for the record:
$ ruby --version ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0] -
Jeff Kreeftmeijer
- State changed from new to open
- Importance changed from to Low
I couldn't reproduce this issue on master or 3.0.4:
# app/models/user.rb class User < ActiveRecord::Base validates :email, :presence => true #validates :name, :presence => true end$ script/rails c Loading development environment (Rails 3.1.0.beta) irb(main):001:0> u = User.new => #<User id: nil, name: nil, email: nil, created_at: nil, updated_at: nil> irb(main):002:0> u.valid? => false irb(main):003:0> u.errors => #<ActiveModel::Errors:0xb7204b50 @base=#<User id: nil, name: nil, email: nil, created_at: nil, updated_at: nil>, @messages=#<OrderedHash {:email=>["can't be blank"]}>> # Now, before reloading and without leaving the console, I uncomment the :name validation in the user model. irb(main):004:0> reload! Reloading... => true irb(main):005:0> u = User.new => #<User id: nil, name: nil, email: nil, created_at: nil, updated_at: nil> irb(main):006:0> u.valid? => false irb(main):007:0> u.errors => #<ActiveModel::Errors:0xb6d3ed00 @base=#<User id: nil, name: nil, email: nil, created_at: nil, updated_at: nil>, @messages=#<OrderedHash {:email=>["can't be blank"], :name=>["can't be blank"]}>> -
Jeff Kreeftmeijer
- State changed from new to needs-more-info
- Assigned user set to Jeff Kreeftmeijer
Sorry, in my last comment I previously confirmed the issue, but I was doing something wrong. I can't reproduce this issue and I updated my last comment.
Can anyone else reproduce this? If not, I'll mark this one as invalid. :)
-
William Denniss
Hi Jeff,
Thank you for testing this. I'm sorry for not creating a better bug report, it seems that the test case in #3822 reload! doesn't reload does in fact pass. I had reload! problems in 3.0.4, and incorrectly assumed that #3822 reload! doesn't reload had regressed exactly.
Please see the updated bug report above for a test case that fails in 3.0.4.
Thanks again for your time.
Best Regards,
Will -
Jeff Kreeftmeijer
- State changed from needs-more-info to open
Thanks Will, I tried to reproduce again:
# app/models/user.rb class User < ActiveRecord::Base def reloaded? false end end$ script/rails c Loading development environment (Rails 3.1.0.beta) irb(main):001:0> u = User.new => #<User id: nil, name: nil, email: nil, created_at: nil, updated_at: nil> irb(main):002:0> u.reloaded? => false irb(main):003:0> reload! Reloading... => true irb(main):004:0> u.reloaded? => false irb(main):005:0> u = User.new => #<User id: nil, name: nil, email: nil, created_at: nil, updated_at: nil> irb(main):006:0> u.reloaded? => trueAgain, before calling
reload!, I changed the model to makeUser#reloaded?returntrue. When I call that method on the existinguobject, it still returnsfalseafter reloading. When I create a newUserobject,#reload?returnstrue.This confirms your issue on master, I'll re-open the ticket and I'll have a look at it as soon as I can. :)
-
William Denniss
Thanks for looking into it Jeff! Glad you were able to repro it.
-
Jeff Kreeftmeijer
- State changed from open to wontfix
Hi William,
After talking to Josh about this, we came to this conclusion:
The
uobject doesn't get reloaded because it already existed before the model changed andreload!only takes care of the model in this case. I'm marking this one as wontfix, since reloading instances of objects is notreload!'s job, it simply reloads the environment.Thanks for reporting! :)