I just tried upgrading our application to Rails 2.1 on JRuby 1.1.2,
ActiveRecordJDBC 0.8.1 (the versions that are bundled with the nightly
build of NetBeans). The problem I’m having seems to be calling ‘min’
on an association. Here is a simple example:
require ‘rubygems’
gem ‘activerecord’
gem ‘activerecord-jdbc-adapter’
require ‘active_record’
ActiveRecord::Base.establish_connection({
:adapter => ‘mysql’,
:driver => ‘com.mysql.jdbc.Driver’,
:host => ‘localhost’,
:database => ‘sandbox_dev’,
:username => ‘root’
})
class Person < ActiveRecord::Base; has_many :addresses; end
class Address < ActiveRecord::Base; belongs_to :person; end
person = Person.find :first
puts person.addresses.first.street1
puts person.addresses.min{|a,b| a.street1 <=> b.street1}
The second last line is just there to verify that the objects in the
collection respond to street1. The last line produces this:
/lib/main.rb:19: undefined method street1' for #<Array:0xb85495> (NoMethodError) from /jruby-1.1.2/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/associations/association_collection.rb:274:in
method_missing’
from /jruby-1.1.2/lib/ruby/gems/1.8/gems/activerecord-2.1.0/
lib/active_record/associations/association_proxy.rb:175:in each' from /jruby-1.1.2/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/associations/association_proxy.rb:175:in
min’
from /jruby-1.1.2/lib/ruby/gems/1.8/gems/activerecord-2.1.0/
lib/active_record/associations/association_proxy.rb:175:in
method_missing' from /jruby-1.1.2/lib/ruby/gems/1.8/gems/activerecord-2.1.0/ lib/active_record/associations/association_collection.rb:274:in
method_missing’
from /lib/main.rb:19
This code (minus the inclusion of the jdbc adapter) works fine in
MRI. Any suggestions?
thanks,
Darcy.
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email