require "rubygems"
require "activerecord"
# Use the following line instead (without the comment hash) if you are using JRuby
#require "active_record"
#Change this to reflect your database settings
ActiveRecord::Base.establish_connection (
:adapter => "mysql",
:host => "localhost",
:username => "root",
:password => "password",
:database => "some_database")
#Now define your classes from the database as always
class SomeClass < ActiveRecord::Base
#blah, blah, ......
阅读全文