"mysql..." />

How to use ActiveRecord in a ruby script outside Rails?

Require "rubygems" require "activerecord" #Change this to reflect your database settings ActiveRecord::Base. Establish_connection ( :adapter => "mysql", :host => "localhost", :username => "root", :password => "password", :database => "some_database") #Now define your classes from the database as always class SomeClass Find :all.

– Daniel Cukier Oct 29 '09 at 14:10 2 The require_gem call is deprecated. It should be require "activerecord" now. – kafuchau Oct 29 '09 at 14:13 @kchau: Oh, thanks.

I haven't used it in quite some time. – Pesto Oct 29 '09 at 14:17 Another related question: how to have an environment sensible database. Yml?

– Daniel Cukier Oct 29 '09 at 15:42.

It's worth noting that in later versions of activerecord (v3+) you need to require it like so require "active_record.

Activerecord in a ruby script outside rails is used (without quotes):. Use ActiveRecord in a ruby script outside Rails.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions