I am migrating a project from MRI Ruby and Rails 2.x to JRuby and Rails
3. The app is not very complex, but it does use two databases - one
Postgres database that is the main application database, and one SQL
Server database from which I bring in some extra information (I do not
write to this DB or do any migrations on it)
This worked well until the port. Accessing the SQL Server database now
gives this error:
undefined method `identity=’ for
#ActiveRecord::ConnectionAdapters::JdbcColumn:0x13d285f
Oddly enough, if I start “rails console” and use the AR model that is
connected to SQL Server, I can run queries just fine, including the one
that caused the error above.
I spent some time trying to find a minimal repro, and have attached a
ZIP file containing my minimal rails app that is a repro for this
problem. First, some general information. Gems referred to in my
Gemfile:
- rails 3.0.1
- activerecord-jdbcpostgresql-adapter 1.1.1
- activerecord-jdbcmssql-adapter 1.1.1
User is an AR class referencing the postgres database
Registration is an AR class referencing the SQL Server database.
The test controller that produces the problem:
class TestController < ApplicationController
def index
@cur_user = User.find_or_create_by_name(“bob”)
Registration.find_all_by_activation_id(:first)
render :text => “hi”
end
end
Commenting out the line starting with @cur_user causes the problem to
stop happening.
Any ideas what might be going on here? Is this a JRuby or JDBC issue?
Thanks
Andrew