ActiveRecord problems after upgrade

Hi

I have a rather large project that uses ActiveRecord both with Rails,
and separately in various scripts. All has been working well until
I upgraded from version 2.0.2 to version 2.2.2. Now, ActiveRecord
doesn't seem to be looking for the correct table. Here's an example
of what I'm seeing.

  class ActiveRecord::Base
    def self.get_dbconf
      conf = Hash.new
      IO.foreach("/etc/dbconf") do |line|
        next if line.length == 0
        name, data = line.split(": ")
        conf[name] = data.chomp
      end
      return conf
    end
    Conf = get_dbconf
  end
end

class Scode < ActiveRecord::Base
    Scode.establish_connection(self::Conf)
end

irb(main):001:0> require 'scode'
=> true
irb(main):002:0> Scode
=> Scode(Table doesn't exist)
irb(main):003:0> Scode.table_name
=> "\e[4mScode\e[0ms"

I know I can set the table name manually, but if this simple mechanism
is broken, how much other stuff is broken in this version?

Ken

class Scode < ActiveRecord::Base
   Scode.establish_connection(self::Conf)
end

irb(main):001:0> require 'scode'
=> true
irb(main):002:0> Scode
=> Scode(Table doesn't exist)
irb(main):003:0> Scode.table_name
=> "\e[4mScode\e[0ms"

I know I can set the table name manually, but if this simple mechanism
is broken, how much other stuff is broken in this version?

Something to do with the connection pooling changes ?

Fred

Quoth Frederick Cheung (frederick.cheung@gmail.com):

>
>
> class Scode < ActiveRecord::Base
> Scode.establish_connection(self::Conf)
> end
>
> irb(main):001:0> require 'scode'
> => true
> irb(main):002:0> Scode
> => Scode(Table doesn't exist)
> irb(main):003:0> Scode.table_name
> => "\e[4mScode\e[0ms"
>
> I know I can set the table name manually, but if this simple mechanism
> is broken, how much other stuff is broken in this version?
>
Something to do with the connection pooling changes ?

I think it may have something to do with changes to ActiveSupport.
I notice that on my production system (v2.0.2), when I load an
ActiveRecord class, the Inflector class is available:

irb(main):001:0> require 'scode'
=> true
irb(main):002:0> Inflector
=> Inflector

On the test system (v2.2.2), it is not:

irb(main):002:0> require 'scode'
=> true
irb(main):003:0> Inflector
NameError: uninitialized constant Inflector
        from /pkg/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in `load_missing_constant'
        from /pkg/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:77:in `const_missing'
        from /pkg/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:89:in `const_missing'
        from (irb):3
irb(main):004:0> ActiveSupport::Inflector
=> ActiveSupport::Inflector

Ken

Quoth Frederick Cheung (frederick.cheung@gmail.com):

>
>
> class Scode < ActiveRecord::Base
> Scode.establish_connection(self::Conf)
> end
>
> irb(main):001:0> require 'scode'
> => true
> irb(main):002:0> Scode
> => Scode(Table doesn't exist)
> irb(main):003:0> Scode.table_name
> => "\e[4mScode\e[0ms"
>
> I know I can set the table name manually, but if this simple mechanism
> is broken, how much other stuff is broken in this version?
>
Something to do with the connection pooling changes ?

In the end, the problem was fixed by moving a require (which requires
a class completely unrelated to ActiveRecord anything) *above* the
require which pulls in my activerecord classes.

Can't say that I much like the fragility of the arrangement.

Ken