Junkone
11/9/2007 1:11:00 AM
On Nov 8, 1:53 pm, Marcin Raczkowski <mailing...@gmail.com> wrote:
> datab.rb:
>
> require 'rubygems'
> require 'activerecord'
> require 'yaml'
> require 'logger'
>
> class DataB
> def connect_to_db(environment="development")
> conf = YAML::load(File.open(File.dirname(__FILE__) +
> /config/database.yml'))
> ActiveRecord::Base.logger = Logger.new("log/active_record.log")
> ActiveRecord::Base.establish_connection(conf[environment])
> end
>
> def load_models()
> ["model/list.rb",
> "model/models.rb","model/here.rb","model/or_use_File.glob"].each do |lib|
> require lib
> end
> end
> end
>
> ---------------------------
> @db=DataB.new
> @db.connect_to_db
> @db.load_models
>
> and you're ready to go!
thanks. it works