# Reload! in console?

**URL:** <https://www.ruby-forum.com/t/reload-in-console/195030>\
**Category:** Rails\
**Created:** [September 15, 2010, 4:08pm UTC](https://www.ruby-forum.com/t/reload-in-console/195030 "2010-09-15T16:08:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hostep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a88e57/32.png) [@hostep](https://www.ruby-forum.com/u/hostep)\
**Post date:** [September 15, 2010, 4:08pm UTC](https://www.ruby-forum.com/t/reload-in-console/195030/1 "2010-09-15T16:08:41Z")

</div>

hi Guys

I’m doing changes to a model, and testing the changes interactively in  
the console. After saving a change to the model I use ‘reload!’ in the  
console. It seems that the objects that I were working with still exist  
in the console, but in some weird state and I cant really work with  
them. So I have to reinstantiate the objects again with a Object.find…

This is a pain - is there a better way to do this?

Thanks!

Pieter

---

<div class="post-metadata">

**Author:** ![hostep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a88e57/32.png) [@hostep](https://www.ruby-forum.com/u/hostep)\
**Post date:** [September 15, 2010, 5:53pm UTC](https://www.ruby-forum.com/t/reload-in-console/195030/2 "2010-09-15T17:53:33Z")

</div>

On Sep 15, 3:08 pm, Pieter H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> hi Guys
> 
> I’m doing changes to a model, and testing the changes interactively in  
> the console. After saving a change to the model I use ‘reload!’ in the  
> console. It seems that the objects that I were working with still exist  
> in the console, but in some weird state and I cant really work with  
> them. So I have to reinstantiate the objects again with a Object.find…

None that I know of. Reloading basically discards the existing classes  
and loads a fresh copies. Existing objects are however still instances  
of those zombied classes.

Fred

---

<div class="post-metadata">

**Author:** ![hostep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a88e57/32.png) [@hostep](https://www.ruby-forum.com/u/hostep)\
**Post date:** [September 15, 2010, 7:56pm UTC](https://www.ruby-forum.com/t/reload-in-console/195030/3 "2010-09-15T19:56:26Z")

</div>

Pieter H. wrote:

> hi Guys
> 
> I’m doing changes to a model, and testing the changes interactively in  
> the console. After saving a change to the model I use ‘reload!’ in the  
> console. It seems that the objects that I were working with still exist  
> in the console, but in some weird state and I cant really work with  
> them. So I have to reinstantiate the objects again with a Object.find…
> 
> This is a pain - is there a better way to do this?

Yes. Don’t rely so much on interactive testing; use RSpec and Autotest  
instead.

> Thanks!
> 
> Pieter

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![hostep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a88e57/32.png) [@hostep](https://www.ruby-forum.com/u/hostep)\
**Post date:** [September 16, 2010, 10:35am UTC](https://www.ruby-forum.com/t/reload-in-console/195030/4 "2010-09-16T10:35:33Z")

</div>

Marnen Laibow-Koser wrote:

> Pieter H. wrote:
> 
> > hi Guys
> > 
> > I’m doing changes to a model, and testing the changes interactively in  
> > the console. After saving a change to the model I use ‘reload!’ in the  
> > console. It seems that the objects that I were working with still exist  
> > in the console, but in some weird state and I cant really work with  
> > them. So I have to reinstantiate the objects again with a Object.find…
> > 
> > This is a pain - is there a better way to do this?
> 
> Yes. Don’t rely so much on interactive testing; use RSpec and Autotest  
> instead.

Thanks for the comments guys. I know I need to get into proper testing.  
My usage case is really while I am busy writing the model. Would be  
great if reload! also reloaded the objects I have created in the  
session.

Lemme look into Autotest…

Cheers from South Africa!
