This project is archived and is in readonly mode.

#2771 ✓invalid
Vikrant Chaudhary

reload! in script/console re-defines classes.

Reported by Vikrant Chaudhary | June 6th, 2009 @ 06:43 AM | in 2.x

Try this -

Create a file named lib/a.rb that defines a class A.

#file - lib/a.rb
def A
end

open script/console and type following

Loading development environment (Rails 2.3.2)
>> a = A.new
=> #<A:0x7f0b22b91160>
>> a.class
=> A
>> a.is_a? A
=> true
>> reload!
Reloading...
=> true
>> a.class
=> A
>> a.is_a? A
=> false

As you can see that a is no more an instance of A. This causes an ArgumentError for methods that validate arguments for their class.

You can type following code to see that reload! re-defines classes.

>> A.object_id
=> 70177791147340
>> reload!
Reloading...
=> true
>> A.object_id
=> 70177790965760

Using Rails 2.3.2 on Ubuntu 9.04

-thanks

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>

Tags

Pages