I''m working on an application that periodically wakes up, looks at entries in an Oracle table, and for each relevant row that it finds, processes some XML and generates some files for ftp. I''d love to use Ruby as my ''glue'' language (I''m on Windows so nothing is already installed on the machine and I might as well pick the language I like). Even better, I''d be thrilled if I could use rails and simply point a model at my table and then very easily "find all" with the appropriate conditions and iterate over the results, without worrying about any of the backend database config or environment switching or anything like that. My question is, has anybody done work (possibly with new forms of generators) to create a Rails application that does *not* expect to run as a web server / web service? If I fire up irb I can piece together the necessary require statements to do what I want to do. Has a "best practice" for this evolved yet, or should I just hack up some sort of launcher.rb file that does my dirty work? D -- Posted via http://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---
Hi Duane, On 13 Sep 2006, at 21:18, Duane Morin wrote:> Even better, I''d be thrilled if I could use rails and simply point a > model at my table and then very easily "find all" with the appropriate > conditions and iterate over the results, without worrying about any of > the backend database config or environment switching or anything like > that.It sounds like you''re looking for "standalone ActiveRecord" From: http://wiki.rubyonrails.org/rails/pages/ActiveRecord> "Besides being a stand-alone ORM package for Ruby, Active Record is > also the model part of the web-application framework Rails."ie. you can use ActiveRecord "on its own" (outside the context of a full-stack Rails application) to do exactly what you''re describing. Peter --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> > I''m working on an application that periodically wakes up, looks at > entries in an Oracle table, and for each relevant row that it finds, > processes some XML and generates some files for ftp. I''d love to use > Ruby as my ''glue'' language (I''m on Windows so nothing is already > installed on the machine and I might as well pick the language Ilike).> Even better, I''d be thrilled if I could use rails and simply point a > model at my table and then very easily "find all" with the appropriate > conditions and iterate over the results, without worrying about any of > the backend database config or environment switching or anything like > that. > > My question is, has anybody done work (possibly with new forms of > generators) to create a Rails application that does *not* expect torun> as a web server / web service? If I fire up irb I can piece together > the necessary require statements to do what I want to do. Has a "best > practice" for this evolved yet, or should I just hack up some sort of > launcher.rb file that does my dirty work? >I''ve got a perl app I wrote about five years ago that sounds quite similar. However, I found that I did want a web interface, just so I can admin the master tables, and easily pull reports. You can certainly use ActiveRecord without the need for a complete rails app. Also, I use runner to do things like cleaning my session table from cron: #!/bin/sh export RAILS_ENV="production" /usr/local/rails/mcalogin/current/script/runner \ ''ActiveRecord::Base.connection.delete("DELETE FROM sessions where updated_at < now() - INTERVAL 24 HOUR")'' --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On Wed, Sep 13, 2006 at 10:18:48PM +0200, Duane Morin wrote:> > I''m working on an application that periodically wakes up, looks at > entries in an Oracle table, and for each relevant row that it finds, > processes some XML and generates some files for ftp. I''d love to use > Ruby as my ''glue'' language (I''m on Windows so nothing is already > installed on the machine and I might as well pick the language I like). > Even better, I''d be thrilled if I could use rails and simply point a > model at my table and then very easily "find all" with the appropriate > conditions and iterate over the results, without worrying about any of > the backend database config or environment switching or anything like > that. > > My question is, has anybody done work (possibly with new forms of > generators) to create a Rails application that does *not* expect to run > as a web server / web service? If I fire up irb I can piece together > the necessary require statements to do what I want to do. Has a "best > practice" for this evolved yet, or should I just hack up some sort of > launcher.rb file that does my dirty work?You can make a rails app that never runs in a server, and then use pieces to do what you want. You can use script/runner to run methods in a model, or use code like this to run a controller: #!/usr/bin/env ruby require ''rubygems'' require_gem ''activerecord'' require_gem ''actionpack'' SCRIPT_PATH = File.expand_path(File.dirname(__FILE__)) $LOAD_PATH << "#{SCRIPT_PATH}/../app/models/" $LOAD_PATH << "#{SCRIPT_PATH}/../app/controllers/" $LOAD_PATH << "#{SCRIPT_PATH}/../lib/" require ''application'' require "#{SCRIPT_PATH}/../config/environment.rb" require ''model'' require ''controller'' Model.action SomeController.action etc. Make sure to set the rails_env environment variable: RAILS_ENV=production I use script/runner where possible, but I have to use the above code sometimes, such as when a cron job effects caching. Michael -- Michael Darrin Chaney mdchaney-c1nKWHh82D8TjS1aD1bK6AC/G2K4zDHf@public.gmane.org http://www.michaelchaney.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 -~----------~----~----~----~------~----~------~--~---