Rails 2.1.2 to 2.3.2 problems

I just installed Rails 2.3.2 and tried to upgrade my test app from

2.1.2. After installing Rails 2.3.2, I simply changed the gem version

in my environment.rb file in config directory as shown below:

Specifies gem version of Rails to use when vendor/rails is not present

RAILS_GEM_VERSION = ‘2.3.2’ unless defined? RAILS_GEM_VERSION

The server refuses to start and I get the following stacktrace:

=> Booting Mongrel

=> Rails 2.3.2 application starting on http://0.0.0.0:3000

/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:416:in

initialize_database': undefined method configurations=’ for

ActiveRecord::Base:Class (NoMethodError)

    from

/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:141:in

`process’

    from

/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in

`send’

    from

/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in

`run’

    from /home/bruparel/exp/pizzeria-3/config/environment.rb:13

    from

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in

`gem_original_require’

    from

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in

`require’

    from

/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in

`require’

    from

/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in

`new_constants_in’

    from

/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in

`require’

    from

/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/server.rb:84

    from

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in

`gem_original_require’

    from

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in

`require’

    from script/server:3

Change it back to 2.1.2 and I am fine. Is there something that is

missing? I do a rails -v and it shows that 2.3.2 is installed as shown

below:

bruparel@bcr-d810:~$ rails -v

Rails 2.3.2

bruparel@bcr-d810:~$

Thanks for your time.

Bharat

Hi, did you update your configs?

rake rails:update

-Conrad

Hello Conrad,
I am making good progress towards resolving this, but am not there
entirely. Following is my abbreviated environment.rb file. Note that I
have commented out the RAILS_GEM_VERSION line so that the latest rails
2.3.2 is loaded.

# Specifies gem version of Rails to use when vendor/rails is not present
#RAILS_GEM_VERSION = '2.1.2' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')

Rails::Initializer.run do |config|

  # Add additional load paths for your own custom dirs
  config.load_paths += %W( #{RAILS_ROOT}/app/form_builders )

  config.time_zone = 'UTC'

  config.action_controller.session = {
    :session_key => '_pizzeria_session',
    :secret =>
'1cac89a5ef8e67d30b297648243baee84a52d16dbbf11690733a73c825da43c327a6552f9498d0fe2ecf29cbc09ebf6115102fe3d26f969909f005dc1da39e09'
  }

  require "#{RAILS_ROOT}/lib/active_record_extensions.rb"

end

if I comment out the last require
"#{RAILS_ROOT}/lib/active_record_extensions.rb"

statement as shown below:

# require "#{RAILS_ROOT}/lib/active_record_extensions.rb"

and restart the server then it boots and everything works fine except
where I need the functionality contained in
lib/active_record_extensions.rb file which is as follows:

module ActiveRecord

  class Base
    def self.search(search, current_page, search_field)
      if search.blank?
        paginate(:all, :page => current_page || 1, :per_page => 5)
      else
        paginate(:all, :conditions => ["#{search_field} LIKE ?",
"%#{search}%"], :order => 'name',
          :page => current_page || 1, :per_page => 5)
      end
    end
  end

end

Why does Rails 2.3.2 have a problem with it when 2.1.2 does not? The
error messages are very misleading and point to some problem with
database when there is none?

Figured it out:

Rails 2.3 has a problem with requiring any files within the initializer
block as shown below.

Rails::Initializer.run do |config|

  require "#{RAILS_ROOT}/lib/active_record_extensions.rb"

end

Instead, it wants you to put your require statement outside the block as
shown below:

Rails::Initializer.run do |config|

   .....

end
require "#{RAILS_ROOT}/lib/active_record_extensions.rb"

This works. Why is it so? I do not know. If someone can explain this,
I would appreciate it.

Thanks.

Bharat

ActiveRecord is not loaded at this point. The right place for this
sort of stuff is in an initializer (see
http://www.spacevatican.org/2008/11/21/environment-rb-and-requiring-dependencies
for ways where putting it at the bottom of environment.rb can go
wrong).

Fred