Support a model within a script

Hi,

I want to write a script (something like script/breakpointer) which
recognizes the models in my rails application. I tried inheriting from
my model class, but I get an “uninitialized constant (NameError)”
error. Any suggestions?
Thanks
–Andrei

On 7/27/07, andreim [email protected] wrote:

Hi,

I want to write a script (something like script/breakpointer) which
recognizes the models in my rails application. I tried inheriting from
my model class, but I get an “uninitialized constant (NameError)”
error. Any suggestions?
Thanks

Put your code in a class in the lib directory, say myclass.rb. Define
class methods which will be your entry points.

class Myclass
def self.mymethod
Mymodel.find()
end
end

Then just run script/runner “Myclass.mymethod” -e [environment]