From: Ken Bloom Date: 2006-12-05T11:35:06+09:00 Subject: Re: how do I "unrequire" a file ? On Tue, 05 Dec 2006 10:32:21 +0900, David Vallner wrote: > Tuka Opaleye wrote: >> Hi all, >> >> In using migrate manually, I "require" the file containing the migration >> and run it using console. I later decide to alter the same file on my >> editor and try to run the migration again (after the code below) and >> the changes are not effected. >> >> I understand that when the migtation file is required a second time, it >> is not loaded. how do I then unload it so that i can reload it with the >> fresh changes ? Or is there a better way ? >> > > Use load (ri Kernel#load) instead of require. I -think- you need to use > the .rb with load as opposed to require, but I'm not sure. > > David Vallner Yes, you do need to use the .rb extension with load. require 'file' #would become load 'file.rb' Note that there's no concept of unloading a file -- loading a file again just extends the classes further, overriding any methods that have already been defined. This doesn't work out so well when alias_method metaprogramming techniques come into play. You may also need to be sure not to use any objects created from classes in the old version file.rb, but that will depend on what you change. --Ken -- Ken Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/