0

I would like to use JRuby to run a script which populates a database. I am already running JRuby/Rails for a Rails server in another application, and this setup works.

I ran the script (foo.rb) fine until I tried to include the ActiveRecord gem in line 2. The code looks like this:

require 'rubygems'
require 'activerecord'
require 'csv'
nf=[]
Dir["./*.*"].each{|f|nf<<f if File::ctime(f) + 600 > Time.now} 
nf.each{|f| p f.inspect}

The error I get looks like this:

unix> jruby --1.9 foo.rb
LoadError: no such file to load -- activerecord
require at org/jruby/RubyKernel.java:1047
require at /home/user/.rbenv/versions/jruby-1.6.4/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36
(root) at foo.rb:2

My gem listing includes all of rails 3.0.10, activerecord 3.0.10, activerecord-jdbc-adapter 1.2.0, activerecord-jdbcmysql-adapter 1.2.0.

I also have an environment variable (JRUBY-OPTS=--1.9) which tells JRuby to run version 1.9 when I use Rails.

What am I missing to get JRuby 1.9 to run with ActiveRecord 3.0.10 to hit a MySQL database?

1 Answer 1

4

Change your require to:

require 'active_record'
Sign up to request clarification or add additional context in comments.

2 Comments

I don't f#$%^ believe it! Why use a different symbol for JRuby?
I think it's the same. Name changed somewhere between v2 and v3.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.