This project is archived and is in readonly mode.

#3822 ✓resolved
Mikel Lindsaar

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

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>

Attachments

Referenced by

Pages