Forum: Ruby on Rails ActiveRecord problems after upgrade

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9e6f139fdf4818d7999288c3f8e1ac4e?d=identicon&s=25 Kenneth Dunlap (Guest)
on 2009-02-03 15:05
(Received via mailing list)
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

--

I use the words you taught me. If they don't mean anything any more,
teach me others. Or let me be silent.
                        Samuel Beckett (Clov, Endgame)
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-02-03 15:50
(Received via mailing list)
On 3 Feb 2009, at 14:05, Kenneth Dunlap wrote:
> 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
9e6f139fdf4818d7999288c3f8e1ac4e?d=identicon&s=25 Kenneth Dunlap (Guest)
on 2009-02-03 16:38
(Received via mailing list)
Quoth Frederick Cheung (frederick.cheung@gmail.com):
> > => 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

--

I use the words you taught me. If they don't mean anything any more,
teach me others. Or let me be silent.
                        Samuel Beckett (Clov, Endgame)
9e6f139fdf4818d7999288c3f8e1ac4e?d=identicon&s=25 Kenneth Dunlap (Guest)
on 2009-02-03 19:33
(Received via mailing list)
Quoth Frederick Cheung (frederick.cheung@gmail.com):
> > => 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
--

I use the words you taught me. If they don't mean anything any more,
teach me others. Or let me be silent.
                        Samuel Beckett (Clov, Endgame)
This topic is locked and can not be replied to.