Utility App using rails models

I have a few maintenance programs that run periodically via cron. I
learned how to use rails model files in those apps w/o much problem.
However, the problem came about when one of my models, then many of
my models began using plugins. Now I find that with each new plugin I
use in my models, I have to go back to each of my utility apps and
specifically require that plugin in order for the new model file to
work.

Does anyone have an easier way? My current method is something like:

Database

require ‘rubygems’
require_gem ‘activerecord’

require ‘…/…/vendor/plugins/acts_as_logged/lib/acts_as_logged’
require ‘db_connection’
require ‘…/models/claim’
require ‘…/models/mbr_item_category’

… code …

db_connection is just a little helper file I created so that all my
utils can be centrally configured to connect to the database, it
looks something like:

ActiveRecord::Base.establish_connection({
:adapter => “postgresql”,
:database => ‘ips2_development’,
})

So, see the problem with acts_as_logged?

Thanks for any info,

Jeremy C.

ISTR that if you put your ruby files (‘maintenance programs’) under your
rails directory, and launch them with <RAILS_APP>/script/runner you get
all the rails environment available to your ruby program.

See here:
http://wiki.rubyonrails.org/rails/pages/HowToRunBackgroundJobsInRails

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs