Greg Donald
2008-Jul-28 21:10 UTC
Re: how do I run a Ruby script within the Rails framework (like I was in ./script/console)???
On Mon, Jul 28, 2008 at 3:56 PM, Greg Hauptmann <greg.hauptmann.ruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > Anyone know how do I run a Ruby script within the Rails framework (like I > was in ./script/console)??? > That is, I could do the same things I can do in the Rails console (e.g. > ./script/console), however I can write a script file for this. I have > scripting some data fixes in mind.script/runner "MyClass.my_data_fixes" -- Greg Donald http://destiney.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Greg Hauptmann
2008-Jul-28 21:13 UTC
Re: how do I run a Ruby script within the Rails framework (like I was in ./script/console)???
thanks - so I''m guessing then that "runner" will look in the /lib directory to try to find your file where the class exists? i.e. how does it pick up your script file path/filename? On Tue, Jul 29, 2008 at 7:10 AM, Greg Donald <gdonald-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On Mon, Jul 28, 2008 at 3:56 PM, Greg Hauptmann > <greg.hauptmann.ruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi, > > Anyone know how do I run a Ruby script within the Rails framework (like I > > was in ./script/console)??? > > That is, I could do the same things I can do in the Rails console (e.g. > > ./script/console), however I can write a script file for this. I have > > scripting some data fixes in mind. > > script/runner "MyClass.my_data_fixes" > > > -- > Greg Donald > http://destiney.com/ > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Greg Donald
2008-Jul-28 21:22 UTC
Re: how do I run a Ruby script within the Rails framework (like I was in ./script/console)???
On Mon, Jul 28, 2008 at 4:13 PM, Greg Hauptmann <greg.hauptmann.ruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> thanks - so I''m guessing then that "runner" will look in the /lib directory > to try to find your file where the class exists? i.e. how does it pick up > your script file path/filename?Magic? I''d just build the stuff in a model file. class MyClass < ActiveRecord::Base def self.my_data_fixes # do stuff here end end Then run it like: script/runner "MyClass.my_data_fixes" -- Greg Donald http://destiney.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Christopher Kintner
2008-Jul-28 21:43 UTC
Re: how do I run a Ruby script within the Rails framework (like I was in ./script/console)???
On Mon, Jul 28, 2008 at 4:13 PM, Greg Hauptmann <greg.hauptmann.ruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> thanks - so I''m guessing then that "runner" will look in the /lib directory > to try to find your file where the class exists? i.e. how does it pick up > your script file path/filename?# script/runner --help Usage: script/runner [options] (''Some.ruby(code)'' or a filename) -e, --environment=name Specifies the environment for the runner to operate under (test/development/production). Default: development -h, --help Show this help message.> On Tue, Jul 29, 2008 at 7:10 AM, Greg Donald <gdonald-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> On Mon, Jul 28, 2008 at 3:56 PM, Greg Hauptmann >> <greg.hauptmann.ruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > Hi, >> > Anyone know how do I run a Ruby script within the Rails framework (like >> > I >> > was in ./script/console)??? >> > That is, I could do the same things I can do in the Rails console (e.g. >> > ./script/console), however I can write a script file for this. I have >> > scripting some data fixes in mind. >> >> script/runner "MyClass.my_data_fixes" >> >> >> -- >> Greg Donald >> http://destiney.com/ >> >> > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---