This project is archived and is in readonly mode.

#4229 new
Slava

uninitialized constant ActiveRecord::Base::MysqlCompat

Reported by Slava | March 19th, 2010 @ 04:26 AM

ruby 1.9.2-head
rails 3.0.beta1

Developing a Rails 3 application I created an initializer that loads some date from db.

...
puts "count " + StatSource.all.count.to_s

After adding this initializer when making http requests to the application I get error:

Started GET "/websites/3" for 127.0.0.1 at 2010-03-18 21:03:41

NameError (uninitialized constant ActiveRecord::Base::MysqlCompat):
  

Rendered /home/slava/.rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.0ms)
Rendered /home/slava/.rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.8ms)
Rendered /home/slava/.rvm/gems/ruby-1.9.2-head/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (4.6ms)

if i comment out that line in initializer everything works, error goes away..

Comments and changes to this ticket

  • Matija Folnovic

    Matija Folnovic April 3rd, 2010 @ 12:16 PM

    I'm getting same error, also in initializer ( seems that's initializers issue ), but in rails3.0.beta2!

  • xdanger (at gmail)

    xdanger (at gmail) May 25th, 2010 @ 10:57 AM

    I'm getting same error, also in initializer, in BETA3

  • Neeraj Singh

    Neeraj Singh May 25th, 2010 @ 01:45 PM

    Looks like this is not an issue with ruby 1.8.7. I am not able to produce this error with ruby 1.8.7 and rails edge.

    ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin10.3.0]

  • Neeraj Singh

    Neeraj Singh May 25th, 2010 @ 01:45 PM

    • Tag set to ruby 1.9
  • Daniel Morris

    Daniel Morris May 26th, 2010 @ 02:04 PM

    • Tag changed from ruby 1.9 to rails 3.0.0.beta3, ruby 1.8.7, ruby 1.9

    I'm getting this error with 1.8.7 and rails 3 beta 3

    NameError: uninitialized constant ActiveRecord::Base::MysqlCompat

    from /usr/local/rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:70:in `mysql_connection'
    from /usr/local/rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:226:in `send'
    from /usr/local/rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:226:in `new_connection'
    from /usr/local/rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:248:in `checkout_new_connection'
    from /usr/local/rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in `checkout'
    from /usr/local/rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:186:in `loop'
    from /usr/local/rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:186:in `checkout'
    from /usr/local/rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/monitor.rb:242:in `synchronize'
    from /usr/local/rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:185:in `checkout'
    from /usr/local/rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:99:in `connection'
    from /usr/local/rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:330:in `retrieve_connection'
    from /usr/local/rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:103:in `retrieve_connection'
    from /usr/local/rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:95:in `connection'
    from /usr/local/rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activerecord/lib/active_record/base.rb:758:in `columns'
    from /usr/local/rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activerecord/lib/active_record/persistence.rb:224:in `attributes_from_column_definition'
    from /usr/local/rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activerecord/lib/active_record/locking/optimistic.rb:62:in `attributes_from_column_definition'
    from /usr/local/rvm/gems/ruby-1.8.7-p249/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activerecord/lib/active_record/base.rb:1425:in `initialize'
    
  • ronin-45053 (at lighthouseapp)

    ronin-45053 (at lighthouseapp) May 29th, 2010 @ 06:29 AM

    I can confirm that I get this problem with both ruby 1.8.7 and 1.9.1 on Windows 7 64bit.
    I first noticed it in the rails console after reloading to see my model changes.

    C:\Users\Samuel Kadolph\My Projects\Rails\Genti>rails console
    Loading development environment (Rails 3.0.0.beta3)
    irb(main):001:0> u = User.new
    => #<User id: nil, type: nil, username: nil, ...snip... created_at: nil, updated_at: nil>
    irb(main):002:0> u.username = "Samuel"
    => "Samuel"
    irb(main):003:0> u.password = "abc123"
    => "abc123"
    irb(main):004:0> u.save
    => false
    irb(main):005:0> reload!
    Reloading...
    => true
    irb(main):006:0> u
    NameError: uninitialized constant ActiveRecord::Base::MysqlCompat
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/mysql_adapter.rb:70:in `mysql_connection'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_pool.rb:226:in `send'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_pool.rb:226:in `new_connection'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_pool.rb:248:in `checkout_new_connection'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in `checkout'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_pool.rb:186:in `loop'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_pool.rb:186:in `checkout'
            from C:/Ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_pool.rb:185:in `checkout'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_pool.rb:99:in `connection'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_pool.rb:330:in `retrieve_connection'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_specification.rb:103:in `retrieve_connection'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_specification.rb:95:in `connection'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/base.rb:862:in `columns'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/base.rb:875:in `column_names'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/base.rb:1957:in `inspect'
            from C:/Ruby/lib/ruby/1.8/irb.rb:310:in `output_value'
            from C:/Ruby/lib/ruby/1.8/irb.rb:159:in `eval_input'
            from C:/Ruby/lib/ruby/1.8/irb.rb:271:in `signal_status'
            from C:/Ruby/lib/ruby/1.8/irb.rb:155:in `eval_input'
            from C:/Ruby/lib/ruby/1.8/irb.rb:154:in `eval_input'
            from C:/Ruby/lib/ruby/1.8/irb.rb:71:in `start'
            from C:/Ruby/lib/ruby/1.8/irb.rb:70:in `catch'
            from C:/Ruby/lib/ruby/1.8/irb.rb:70:in `start'
            from C:/Ruby/lib/ruby/gems/1.8/gems/railties-3.0.0.beta3/lib/rails/commands/console.rb:47:in `start'
            from C:/Ruby/lib/ruby/gems/1.8/gems/railties-3.0.0.beta3/lib/rails/commands/console.rb:8:in `start'
            from C:/Ruby/lib/ruby/gems/1.8/gems/railties-3.0.0.beta3/lib/rails/commands.rb:34
            from script/rails:9:in `require'
            from script/rails:9
    irb(main):007:0> User.new
    NameError: uninitialized constant ActiveRecord::Base::MysqlCompat
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/mysql_adapter.rb:70:in `mysql_connection'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_pool.rb:226:in `send'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_pool.rb:226:in `new_connection'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_pool.rb:248:in `checkout_new_connection'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in `checkout'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_pool.rb:186:in `loop'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_pool.rb:186:in `checkout'
            from C:/Ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_pool.rb:185:in `checkout'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_pool.rb:99:in `connection'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_pool.rb:330:in `retrieve_connection'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_specification.rb:103:in `retrieve_connection'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/connection_adapters/abstract/connection_specification.rb:95:in `connection'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/base.rb:862:in `columns'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/base.rb:2105:in `attributes_from_column_definition_without_lock'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/locking/optimistic.rb:55:in `attributes_from_column_definition'
            from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-3.0.0.beta3/lib/active_record/base.rb:1525:in `initialize'
            from (irb):7:in `new'
            from (irb):7
    irb(main):008:0>
    
  • Jeff Kreeftmeijer

    Jeff Kreeftmeijer November 8th, 2010 @ 08:51 AM

    • Tag cleared.
    • Importance changed from “” to “Low”

    Automatic cleanup of spam.

  • bingbing

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages