# Rails 2.1.2 to 2.3.2 problems

**URL:** <https://www.ruby-forum.com/t/rails-2-1-2-to-2-3-2-problems/163890>\
**Category:** Rails\
**Created:** [March 25, 2009, 10:09pm UTC](https://www.ruby-forum.com/t/rails-2-1-2-to-2-3-2-problems/163890 "2009-03-25T22:09:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [March 25, 2009, 10:09pm UTC](https://www.ruby-forum.com/t/rails-2-1-2-to-2-3-2-problems/163890/1 "2009-03-25T22:09:10Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [March 25, 2009, 10:14pm UTC](https://www.ruby-forum.com/t/rails-2-1-2-to-2-3-2-problems/163890/2 "2009-03-25T22:14:35Z")

</div>

On Wed, Mar 25, 2009 at 2:09 PM, Bharat R. \<  
removed\_email\_address@domain.invalid\> wrote:

> =\> Booting Mongrel  
> from
> 
> ```
> from
> 
> ```
> 
> 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

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [March 25, 2009, 10:32pm UTC](https://www.ruby-forum.com/t/rails-2-1-2-to-2-3-2-problems/163890/3 "2009-03-25T22:32:32Z")

</div>

Hello Conrad,  
you wrote:

> Hi, did you update your configs?
> 
> rake rails:update
> 
> -Conrad

No. I had not done that, but after reading your reply I did, but I get  
the same error 🙂 as can be seen below:

bruparel@bcr-d810:~/exp/pizzeria-3$ cd config/  
bruparel@bcr-d810:~/exp/pizzeria-3/config$ vi environment.rb  
bruparel@bcr-d810:~/exp/pizzeria-3/config$ cd …  
bruparel@bcr-d810:~/exp/pizzeria-3$ rake rails:update  
(in /home/bruparel/exp/pizzeria-3)  
/home/bruparel/exp/pizzeria-3/app/controllers/application.rb has been  
renamed to  
/home/bruparel/exp/pizzeria-3/app/controllers/application\_controller.rb,  
update your SCM as necessary  
bruparel@bcr-d810:~/exp/pizzeria-3$ ruby ./script/server  
=\> Booting Mongrel  
=\> Rails 2.3.2 application starting on [http://0.0.0.0:3000](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)

Note that I edited the environment.rb to set Rails Gems to 2.3.2, but it  
does not work.

Bharat

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [March 25, 2009, 11:38pm UTC](https://www.ruby-forum.com/t/rails-2-1-2-to-2-3-2-problems/163890/4 "2009-03-25T23:38:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [March 26, 2009, 12:36am UTC](https://www.ruby-forum.com/t/rails-2-1-2-to-2-3-2-problems/163890/5 "2009-03-26T00:36:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [March 26, 2009, 12:44am UTC](https://www.ruby-forum.com/t/rails-2-1-2-to-2-3-2-problems/163890/6 "2009-03-26T00:44:36Z")

</div>

On Mar 25, 11:36 pm, Bharat R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> 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

ActiveRecord is not loaded at this point. The right place for this  
sort of stuff is in an initializer (see

> **[environment.rb and requiring dependencies - Space Vatican](https://www.spacevatican.org/2008/11/21/environment-rb-and-requiring-dependencies/)**
>
> In the before time, the bottom of most of my apps’ environment.rb was an unholy mess. Inflector rules, requiring of various libraries or gems, …

for ways where putting it at the bottom of environment.rb can go  
wrong).

Fred

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [March 26, 2009, 1:07am UTC](https://www.ruby-forum.com/t/rails-2-1-2-to-2-3-2-problems/163890/7 "2009-03-26T01:07:39Z")

</div>

Thanks Fred. Here is what I did after reading the link that you posted:

I created the config/initializers/load\_lib\_dir.rb with the following  
line of code:

Dir.glob( “#{ RAILS\_ROOT }/lib/\*.rb” ).each { |f| require f } \<-- thanks  
Greg.

I guess, I have some homework to do on the initializers.

Regards,

Bharat

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [November 19, 2009, 8:26pm UTC](https://www.ruby-forum.com/t/rails-2-1-2-to-2-3-2-problems/163890/8 "2009-11-19T20:26:49Z")

</div>

> ActiveRecord is not loaded at this point. The right place for this  
> sort of stuff is in an initializer (see  
> [environment.rb and requiring dependencies - Space Vatican](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

+1  
thanks Fred 🙂

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [March 31, 2009, 2:27am UTC](https://www.ruby-forum.com/t/rails-2-1-2-to-2-3-2-problems/163890/9 "2009-03-31T02:27:38Z")

</div>

Please use  
rake rails:update

After you update your rails version, you should check your app, the  
config file and the plugins.  
Most time ,the errors are happening in the config file(config/  
environments/…) and the plugins.

On Mar 26, 5:09 am, Bharat R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
