Forum: Ruby on Rails support a model within a script

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1d7d0a1c0aabf7d358d318c3426c6bf1?d=identicon&s=25 andreim (Guest)
on 2007-07-27 22:05
(Received via mailing list)
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
F48118fe74b0c7f6fd82a0ee422fa34e?d=identicon&s=25 snacktime (Guest)
on 2007-07-27 22:24
(Received via mailing list)
On 7/27/07, andreim <andreim@gmail.com> 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]
This topic is locked and can not be replied to.