I am very new to the ruby world and I’m trying to get a pretty simple
script to open a database connection read from it do stuff with the
data, write to it and finally close it. However, in the process I’ve
become very confused. Do i need rails to have the database connection?
I looked at JDBC and I can’t figure out how to tell it to open the
connection other than the database.yml file.
If someone could give me a tutorial link for getting the gem and
opening the connection, maybe even looping through the data, that
would be great.
It didn't seem to work? I tried require active_record and it
“failed to find” it??? I’m using jruby/jirb but I tried with ruby/irb
as well and I got the same thing.
sudo jruby -S gem install activerecord
root’s password:
JRuby limited openssl loaded. gem install jruby-openssl for full
support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
Updating metadata for 17 gems from http://gems.rubyforge.org
…
complete
Successfully installed activerecord-2.0.2
1 gem installed
Installing ri documentation for activerecord-2.0.2…
Installing RDoc documentation for activerecord-2.0.2…
jirb
irb(main):003:0> require ‘active_record’
LoadError: no such file to load – active_record
from (irb):4:in require' from (irb):4:in signal_status’
scripts/ruby # gem install activerecord
Need to update 16 gems from http://gems.rubyforge.org
…
complete
Install required dependency activesupport? [Yn] Y
Successfully installed activerecord-2.0.2
Successfully installed activesupport-2.0.2
Installing ri documentation for activerecord-2.0.2…
Installing ri documentation for activesupport-2.0.2…
Installing RDoc documentation for activerecord-2.0.2…
Installing RDoc documentation for activesupport-2.0.2…
irb
irb(main):002:0> require ‘active_record’
LoadError: no such file to load – active_record
from (irb):2:in `require’
from (irb):2
It didn’t seem to work? I tried require active_record and it
“failed to find” it??? I’m using jruby/jirb but I tried with ruby/irb
as well and I got the same thing.
require ‘rubygems’ before you require ‘active_record’
This is not neccesary if you are using the latest version of Ruby (1.8.6
something…)