Ben Bleything
7/31/2007 5:10:00 PM
On Wed, Aug 01, 2007, Ari Brown wrote:
> Can anyone point me to a good tutorial for using ActiveRecord without
> Rails?
> Right now I'm just stealing what information I can from various sources.
What do you need to know? You can (more or less) just install
activerecord, require it, and go to town. You still have to define your
"models" just as you would in Rails, but they don't need to be in
magically named files or anything fancy like that.
You do need to establish the connection by hand, but that's usually as
easy as:
ActiveRecord::Base.establish_connection({
:adapter => 'sqlite3',
:dbfile => '/home/ben/.sqlite/counts.sqlite'
})
of course, whatever would normally go in the database section of your
configuration goes into that little hash.
I use AR outside of Rails every day and haven't had much trouble. If
you're having specific problems, let us know... but for the most part,
there's nothing scary about doing it, just go for it :)
Ben