From: Nick da G Date: 2008-09-20T05:00:44+09:00 Subject: Re: Using Rails App (Models) in my Ruby script. Brian Candler wrote: > Nick da G wrote: >> Hi, All. >> >> I'm writing a script that's going to run on schedule to pull some info >> from a db and dump it into a csv to be ftped >> >> And a similar script to process a csv/excel file we get from a vendor to >> put in our db. >> >> I can use like Ruby DBI or something. >> But I'd much rather use ActiveRecord. Here is the question. >> >> How do I let my ruby script know to include all of my rails goodies. >> Like the Model's I already created? > > script/runner > > (also script/console if you want to have an IRb shell with all the rails > goodies loaded) Hi Brian, thanks for the reply but I guess I didn't make myself clear. script/console would load an interactive console - that's waiting for my input. Not sure how to I would interact with that from my ruby progam and how to load it from my ruby script. I looked into script/runner - but as I understand it is for running Background processing from your rails app - like when you want to process an uploaded video. In anyways I was not able to find a primer that would show how to connect to it from my ruby script - the one that is produced from script/runner -h - doesn't work for me on Mac OS and I can't find any sensible tutorials or examples. What I want is to be able to do is : just load some models from my rails app. Like Product model. so that in my Ruby script I can just do p = Product.find(2), instead of running DBI code. Hope that's clearer. P.S.: Brian do you know of any links or books that would talk more about scrip/runner - I obviously already looked at api and rails wiki. -- Posted via http://www.ruby-forum.com/.