ActiveRecord

D

dbarros

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
 
G

George Moschovitis

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.
 
M

Michael Campbell

George Moschovitis said:
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.
 
G

George Moschovitis

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.
 
D

David Heinemeier Hansson

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 =3D> "Delicious Cakes", :description =3D> "They're yum=
my!"

Again, you need neither explicitly declare name nor description for
this to work.
--=20
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,176
Messages
2,570,949
Members
47,500
Latest member
ArianneJsb

Latest Threads

Top