Forum: Ruby on Rails pointer to standalone ActiveRecord example?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
80870f51df61f7ea3c4d1ca50a0fea43?d=identicon&s=25 Michael Teter (Guest)
on 2006-01-13 18:23
(Received via mailing list)
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
24499e811f19343c7dc406104e9b5785?d=identicon&s=25 Belorion (Guest)
on 2006-01-13 18:44
(Received via mailing list)
Hi Michael,

On 1/13/06, Michael Teter <mtrails@gmail.com> 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 topic is locked and can not be replied to.