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 ?
On Tue, 05 Dec 2006 10:32:21 +0900, David V. wrote:
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 V.
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.