Why do I have to reload the Console

I am new to RoR and trying to learn my way around. I have Bruce Tate's RoR Up And Running book and am using it to learn RoR. An example in chapter 2 page 34 shows how simple it is to add validation for table records. The example adds validation to the ActiveRecord model class Photo.rb as follows:

Class without validation: class Photo < ActiveRecord::Base end

Class with validation: class Photo < ActiveRecord::Base    validates_presence_of :filename end

The MySQL table that this class is managing is as follows:

Think of it this way... when you start console you are in *one* session. Just like if you change a model in the middle of making a request via your browser, it's not going to update. In other words, every instance of console is a "browser hit".

You can type "reload!" and it will reload all the classes. This could invalidate some of your previously find'ed objects though so you might have to re-find them.


Bharat, You can reload a class by typing load ‘classname.rb’

in the console…


Thanks Nathan. As you can tell, I am really new to Rails. Is there a place/book/tutorial where I can find answers for console related questions? I find the console to be very useful tool while learning and would like to know all the commands and tricks like the one you mention above. Regards, Bharat

Thanks you all gentlemen for your helpful comments. I am going to enjoy being a part of RoR community. Regards, Bharat