Support a model within a script


#1

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


#2

On 7/27/07, andreim removed_email_address@domain.invalid 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]