How easy is using ActiveRecord in a non RoR application?

  • Thread starter Iñaki Baz Castillo
  • Start date
I

Iñaki Baz Castillo

Hi, I plan to use ActiveRecord in a non RubyOnRails application (just pure=
=20
Ruby app). How easy is it? is just loading the library?

=2D-=20
I=C3=B1aki Baz Castillo
 
B

Bryan Richardson

It's pretty much easy as pie. :) It's along the lines of

require 'rubygems'
require 'active_record'

class Model < ActiveRecord::Base
has_many :eek:ther_models
belongs_to :parent_model

...

end

There's other database modeling packages out there as well that you could
consider too -- Sequel, DataMapper, etc...
 
G

Gregory Brown

Hi, I plan to use ActiveRecord in a non RubyOnRails application (just pur= e
Ruby app). How easy is it? is just loading the library?

Very easy. I wrote a long article about it a while back:
http://www.oreillynet.com/pub/a/ruby/2007/06/21/how-to-build-simple-console=
-apps-with-ruby-and-activerecord.html

But you'll only need bits and pieces of it to get rolling.

-greg

--=20
Technical Blaag at: http://blog.majesticseacreature.com | Non-tech
stuff at: http://metametta.blogspot.com
 
J

Junkone

Hi, I plan to use ActiveRecord in a non RubyOnRails application (just pure
Ruby app). How easy is it? is just loading the library?

easy. i use activerecord in my db operations as i dont have to break
my head for sql operations. u just create a model class and requrie it
and use it just as u would do in rails.

require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:host => "localhost",
:database => "mydb",
:username => "root"
)
class Tag < ActiveRecord::Base
set_table_name "tags"
has_and_belongs_to_many :trades

end
 
I

Iñaki Baz Castillo

El Lunes, 11 de Agosto de 2008, I=C3=B1aki Baz Castillo escribi=C3=B3:
Hi, I plan to use ActiveRecord in a non RubyOnRails application (just pure
Ruby app). How easy is it? is just loading the library?

Thanks to all, it really seems easy :)

=2D-=20
I=C3=B1aki Baz Castillo
 

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

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top