I was wondering if ActiveRecord support was available for database
access without requiring Ruby on Rails? Just for regular Ruby scripts?
Cheers,
Diego
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
Cheers,
Diego
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.
> > 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
> > 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
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.
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