Pointer to standalone ActiveRecord example?

I’m seeking pointers to example code (ideally complete, small
programs) in Ruby that use ActiveRecord without Rails.

An added bonus would be if they happen to connect to SQL Server, but
I’ll take what I can get. Mainly I just need a jump-start to using
ActiveRecord outside Rails.

Thanks much.
MT

Hi Michael,

On 1/13/06, Michael T. [email protected] wrote:

I’m seeking pointers to example code (ideally complete, small
programs) in Ruby that use ActiveRecord without Rails.

An added bonus would be if they happen to connect to SQL Server, but
I’ll take what I can get. Mainly I just need a jump-start to using
ActiveRecord outside Rails.

I can’t point to any examples, but I just happened to be working on
one
right now.

It’s quite simple:

require ‘author’ # Your model which inherits from ActiveRecord::Base
ActiveRecord::Base.establish_connection (
:adapter => “mysql”,
:host => “host”,
:username => “username”,
:password => “password”,
:database => “database”
)
Author.find(:all)
ActiveRecord::Base.remove_connection()

-Matt

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