Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ActiveRecord

4 views
Skip to first unread message

dba...@gmail.com

unread,
Jul 27, 2005, 2:34:21 AM7/27/05
to
Hi all,

I was wondering if ActiveRecord support was available for database
access without requiring Ruby on Rails? Just for regular Ruby scripts?

Cheers,
Diego

Dick Davies

unread,
Jul 27, 2005, 3:43:21 AM7/27/05
to
* dba...@gmail.com <dba...@gmail.com> [0737 07:37]:

> Hi all,
>
> I was wondering if ActiveRecord support was available for database
> access without requiring Ruby on Rails? Just for regular Ruby scripts?

gem install activerecord

--
'Olympic athletes. Disguise the fact that you've taken anabolic steroids by running a bit slower.'
-- B. Johnson, Canada
Rasputin :: Jack of All Trades - Master of Nuns


dba...@gmail.com

unread,
Jul 27, 2005, 3:52:28 AM7/27/05
to
Thanks Dick. Appreciate it!

Cheers,
Diego

George Moschovitis

unread,
Jul 28, 2005, 3:00:54 AM7/28/05
to
> I was wondering if ActiveRecord support was available for database
> access without requiring Ruby on Rails? Just for regular Ruby scripts?

If you don't need the rest of Rails's infrastructure have a look at Og
(ObjectGraph) an alternative Ruby Object Relational Mapping library. It
may be just what you need for regular Ruby scripts.

Have a look at: http://www.nitrohq.com

regards,
George.

Jim Freeze

unread,
Jul 28, 2005, 7:41:33 AM7/28/05
to
* George Moschovitis <george.mo...@gmail.com> [2005-07-28 16:06:03 +0900]:

> > I was wondering if ActiveRecord support was available for database
> > access without requiring Ruby on Rails? Just for regular Ruby scripts?

Yes. Just

require 'ruby_gems'
require 'active_record'

and away you go.

--
Jim Freeze


Michael Campbell

unread,
Jul 28, 2005, 9:34:32 AM7/28/05
to
"George Moschovitis" <george.mo...@gmail.com> writes:

> > I was wondering if ActiveRecord support was available for database
> > access without requiring Ruby on Rails? Just for regular Ruby
> > scripts?
>
> If you don't need the rest of Rails's infrastructure have a look at
> Og (ObjectGraph) an alternative Ruby Object Relational Mapping
> library. It may be just what you need for regular Ruby scripts.


As was noted, AR is perfectly usable (and installable) w/o all the
other rails related stuff.

--
Michael Campbell

George Moschovitis

unread,
Jul 28, 2005, 11:44:04 AM7/28/05
to
> As was noted... stuff.

Did I say otherwise?

I just argued that Og is better suited for quick stand alone scripts,
as you don't have to create schemas, you can use standard Ruby objects,
etc.

My point is: If you are building a RoR project, you have to use AR.
Otherwise, you can more easily consider Og.

regards,
-g.

--
http://www.nitrohq.com

David Heinemeier Hansson

unread,
Jul 28, 2005, 1:06:39 PM7/28/05
to
> I was wondering if ActiveRecord support was available for database
> access without requiring Ruby on Rails? Just for regular Ruby scripts?

Unless your database schema is too far off the Rails path (such as
using composite primary keys), Active Record works very well on
standard alone scripts. The great thing is that Active Record will
just mirror your database structure into the objects, so just by
defining:

class Product < ActiveRecord::Base
end

You'll have an interface to the products database with all the fields
available as properly type-casted attributes, so you can do
Product.find(1).name without first defining that Product does indeed
have a name, as stated in the database already by the field "name".

And of course, it'll work for creating too:

Product.create :name => "Delicious Cakes", :description => "They're yummy!"

Again, you need neither explicitly declare name nor description for
this to work.
--
David Heinemeier Hansson
http://www.loudthinking.com -- Broadcasting Brain
http://www.basecamphq.com -- Online project management
http://www.backpackit.com -- Personal information manager
http://www.rubyonrails.com -- Web-application framework


0 new messages