This project is archived and is in readonly mode.
reload! doesn't reload
Reported by Mikel Lindsaar | January 31st, 2010 @ 01:53 AM | in 3.0.2
using reload! in the console does not reload the models.
Rails master clone (from 31st of Jan) on Ruby 1.8.7
To reproduce:
Make a model, users, add a validation:
class User < ActiveRecord::Base
validates :email, :presence => true
end
Open the console and do the following:
>> u = User.new
=> #<User id: nil, name: nil, email: nil, created_at: nil, updated_at: nil>
>> u.valid?
=> false
>> u.errors
=> #<OrderedHash {:email=>["can't be blank"]}>
# Added in validations on name "validates :name, :presence => true"
>> reload!
Reloading...
=> true
>> u = User.new
=> #<User id: nil, name: nil, email: nil, created_at: nil, updated_at: nil>
>> u.valid?
=> false
>> u.errors
=> #<OrderedHash {:email=>["can't be blank"]}>
# changes to validation on name are missing
Also, reload! not picking up Ruby syntax errors and returns true even with a ruby syntax error, to reproduce:
>> u = User.new
=> #<User id: nil, name: nil, email: nil, created_at: nil, updated_at: nil>
>> u.valid?
=> false
>> u.errors
=> #<OrderedHash {:email=>["can't be blank"]}>
# Added in validations on name "validates :name, :presence true"
# note the missing => in the options hash
>> reload!
Reloading...
=> true
>> u = User.new
=> #<User id: nil, name: nil, email: nil, created_at: nil, updated_at: nil>
>> u.valid?
=> false
>> u.errors
=> #<OrderedHash {:email=>["can't be blank"]}>
# changes to validation on name are missing
Comments and changes to this ticket
-
RomD February 7th, 2010 @ 08:13 PM
Same problem here.
I have to close and reopen the console to see the changes after using 'rake db:migrate'. -
marcolz February 8th, 2010 @ 11:39 AM
- Tag changed from activerecord, console, reload to activerecord, activeresource, console, reload, reload!
Same here, also when attempting to reload an ActiveResource::Base class, with Rails 3.0.0.beta.
-
marcolz February 8th, 2010 @ 12:02 PM
- Tag changed from activerecord, activeresource, console, reload, reload! to development environment, activerecord, activeresource, console, reload, reload!
It's a problem related not only to the console, but to the entire development environment: even though
grep cache_classes config/environments/development.rb
reads "config.cache_classes = false", still the models are not reloaded. -
Fernando Blat February 21st, 2010 @ 04:18 PM
The actual reload callbacks seem to have been disappeared in the transition to the new callback system for Rails 3.
I am attaching a patch which restores all the callbacks needed to reset ActiveRecord and ActiveSupport, just like it did in Rails 2.3.x
-
José Valim February 21st, 2010 @ 07:34 PM
- Assigned user set to José Valim
-
Christos Zisopoulos February 24th, 2010 @ 04:31 PM
Using
reload!
in the console is not working for me either (Rails 3.0.0.beta1 and any Ruby 1.8.7/1.9.1)The patch seems to fix it.
+1
-
Repository February 26th, 2010 @ 11:15 AM
(from [e6dffb70e6c1d524eeb5a40e1f8e01b067781143]) reload! on console now works as expected. [#3822 status:resolved] http://github.com/rails/rails/commit/e6dffb70e6c1d524eeb5a40e1f8e01...
-
Jeremy Kemper October 15th, 2010 @ 11:01 PM
- Milestone set to 3.0.2
- Importance changed from to High
-
William Denniss February 18th, 2011 @ 07:43 AM
This is broken again in 3.0.4.
I have logged a new bug #6447 for the regression as I see no way to re-open this bug.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 3822 reload! doesn't reload (from [e6dffb70e6c1d524eeb5a40e1f8e01b067781143]) reload!...
- 6447 reload! doesn't reload It appears #3822 has regressed. The test case from that b...
- 6447 reload! doesn't reload It appears #3822 has regressed. The test case from that b...
- 6447 reload! doesn't reload Thank you for testing this. I'm sorry for not creating a ...
- 6447 reload! doesn't reload Thank you for testing this. I'm sorry for not creating a ...