I am simply running Rails from a "C:\rails" directory, where I just unpack the non-gem Rails distribution zip file. I'm not very intimate with the typical Rails deployment scenario, but I'll be looking at that more now that things are starting to work. I am not installing Rails as a gem right now, preferring to just run it directly.
Tom may be doing things a bit differently. Any suggestions in this area would be appreciated, since we're still figuring out how Rails should look and feel under JRuby. Obviously if we're going to deploy to a Java-based app server, it's going to be a bit different from a typical Rails setup.
It's been a to-do for a while to get Date and friends mapping to equivalents in Ruby automatically. It will require some changes to the Java integration layer, but I don't expect those changes will be very difficult. I'll take a look at it and see if anything can be done quickly to get it basically working.
Thanks for your help! I think you're right about the cooler uses of ActiveRecord working on their own once we get the adapter cleaned up and working well. If we get to that point and want to do some deeper tests, we could also try looking at the Camping web framework; it has a much lighter-weight request/response mechanism backed by ActiveRecord, and would provide a good way to test ActiveRecord without the rest of Rails.
- Charlie
On 3/20/06, Nick Sieger <[EMAIL PROTECTED]> wrote:
Inspired by Charlie's reports of progress on the generator scripts, I wanted to chime in here that I'm making some small progress on using ActiveRecord on JRuby. I've been putting in a couple hours here and there and have been able to require ActiveRecord, connect to a MySQL database over JDBC, and execute a manual select statement over the JDBC connection. I'm not really exercising the real ActiveRecord magic yet, hopefully once I get the JDBC adapter more flushed out progress on that will come much more quickly.
A couple of questions:
* I've been writing all ruby code so far -- if I package up a patch, where should this code go? Do the other developers have a standard place where you're installing Rails code? I have a directory in my tree called "site-lib" (looking for a better name/place) into which I downloaded Rails 1.0, and in my test scripts, I'm doing the following. I also have my jdbc_adapter.rb in a src/vendor directory.
$:.unshift(File.dirname(__FILE__) + '/../../src/vendor')
$:.unshift(File.dirname(__FILE__) + '/../../site-lib/rails/vendor/rails/activerecord/lib')
$:.unshift(File.dirname(__FILE__) + '/../../site-lib/rails/vendor/rails/activesupport/lib')
* Any suggestions on the best way to convert java.sql.Date, Time, and Timestamp to ruby equivalents? RIght now all I have is Time.at(javaDate.getTime()) which doesn't seem to be appropriate.
Here's what I have working. I had to run a regular ruby setup script 'confidenceBuilderSetup.rb' in the zip [1] to get the MySQL database and table set up.
require 'test/minirunit'
require 'test/rails/pathsetup'
RAILS_CONNECTION_ADAPTERS = ['abstract', 'jdbc']
require 'active_record'
connspec = ActiveRecord::Base.establish_connection(
:adapter => 'jdbc',
:driver => 'com.mysql.jdbc.Driver',
:url => 'jdbc:mysql://localhost:3306/weblog_development',
:username => 'blog',
:password => ''
)
connection = ActiveRecord::Base.connection
results = connection.execute "select * from entries"
test_equal results.length, 1
row = results.first
test_equal 'First post', row['title']
test_equal 'First post d00d!', row['content']
puts row.inspect
Comments appreciated!
/Nick
[1] http://radio.weblogs.com/0141460/gems/ar-early.zip
--
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ jruby.sourceforge.net
Application Architect @ www.ventera.com
