Updated 'gem'-unintialized constant ActiveRecord?

I would REALLY appreciate help with this. It’s driving me crazy, and
I’ve accidentally messed up my app.

I was working on something that asked me to do a ‘gem update --system’.
So I did. And then it broke my app.

First it was complaining about “require_gem”. Okay, I hunted down that
that’s obsolete, and I had to fix my old config/boot.rb to be the new
config/boot.rb that rails today would generate, without obsolete code.
Good enough. I did that, now my app gets further. But still won’t start
up.

Huh, how can it not find ActiveRecord, what the heck?

Exiting
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:267:in
load_missing_constant': uninitialized constant ActiveRecord (NameError) from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:453:inconst_missing’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:465:in
const_missing' from /usr/local/home/rochkind/U2/config/environment.rb:23 from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:ingem_original_require’
from
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in require' from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:496:inrequire’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:343:in
new_constants_in' from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:496:inrequire’
… 21 levels…
from
/usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/commands/server.rb:39
from
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
from ./script/server:3

I was working on something that asked me to do a ‘gem update --system’.
So I did. And then it broke my app.

Why did you need to run the gem command?

Which platform are you on? Mac OS X? Some gem operations seem to
break gem installs.

T K wrote:

I was working on something that asked me to do a ‘gem update --system’.
So I did. And then it broke my app.

Why did you need to run the gem command?

Which platform are you on? Mac OS X? Some gem operations seem to
break gem installs.

I am on Linux, Red Hat.

I installed the ruby-prof gem, and then put the plugin into a little
test app, to test it out. When I tried to start the test app, it told me
I needed to update all my gems. So I (stupidly) did. Gem dependency
issues are killing me here.

Okay, I kind of sort of figured it out. But I still don’t understand.

I have this in my environment.rb:

ActiveRecord::Base.allow_concurrency = true

[Let’s not get started on whether you can do this with Rails or not.
Just trust me, you can if you’re careful. :slight_smile: ]

That used to work fine. After I updated gems, somehow ActiveRecord
wasn’t defined yet in environment.rb (missing constant error)? I don’t
get it.

If I add: require ‘active_record’ to the top of my environment.rb, it
works again—but I’m worried that manually requiring active_record is
going to get around Rails mechanisms of freezing versions and such. But
also, I don’t understand why this is neccesary. Why isn’t ActiveRecord
yet defined in environment.rb? Huh?

Jonathan R. wrote:

T K wrote:

I was working on something that asked me to do a ‘gem update --system’.
So I did. And then it broke my app.

On 9 Apr 2008, at 16:37, Jonathan R. wrote:

yet defined in environment.rb? Huh?

Where in environment.rb do you have that? ActiveRecord is only going
to be defined once the initialisation process has loaded ActiveRecord.
Any point after the Rails::Initializer.run … block should be fine.

Fred

So this blog post confirms that you can’t access ActiveRecord inside the
config block.
http://toolmantim.com/article/2006/12/27/environments_and_the_rails_initialisation_process

The only mystery to me is why I used to be able to in Rails 1.2.1
before I updated my ‘gem’ gem! But okay, I’ll put it in a
config.after_initialize instead. For the record, and anyone else google
searching on this problem.

Very weird, I still don’t understand why this used to work (and why
there’s so much code on the web, and I think in the Agile Dev book, that
assumes you can reference ActiveRecord in the config block!).

Thanks all for the help.

Jonathan

Jonathan R. wrote:

Frederick C. wrote:

On 9 Apr 2008, at 16:37, Jonathan R. wrote:

yet defined in environment.rb? Huh?

Where in environment.rb do you have that? ActiveRecord is only going
to be defined once the initialisation process has loaded ActiveRecord.
Any point after the Rails::Initializer.run … block should be fine.

Fred

Thanks.

It’s inside the Rails::Initializer.run block. This used to work. For
some reason it stopped working when I updated my ‘gem’ gem (still using
the same version of Rails, 1.2.1). But is this not supposed to be done
this way? I find lots of sample code on the web that references
ActiveRecord inside the Rails::Initializer.run block?

Um…

From what you say, you’ve ripped out your boot.rb file and replaced
it, but not replaced the rest of your app!

If I were you, from my experience, I’d be rebuilding your app around a
new rails generated skeleton.

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #3 out NOW!
http://sensei.zenunit.com/

Are there any guides anywhere to doing that? This is a very large app.
I am a bit anxious over the idea of “rebuilding my app around a new
rails generated skeleton”.

My issue is that this app was originally built for Rails 1.2.1, but I
want to get it working on 1.2.6. It seems as if there were some
significant changes to Rails skeleton files between these versions.

If I generate a new 1.2.6 app, and then take ALL the skeleton files and
pop them into my app, should that work? It’s a lot easier for source
control than taking the skeleton and trying to move all my own files
into it (I want to go the other way instead).

Thanks for any advice. Rails backwards compatibility (or lack thereof)
is turning into rather a nightmare for me!

Jonathan

Julian L. wrote:

Um…

From what you say, you’ve ripped out your boot.rb file and replaced
it, but not replaced the rest of your app!

If I were you, from my experience, I’d be rebuilding your app around a
new rails generated skeleton.

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #3 out NOW!
http://sensei.zenunit.com/

Frederick C. wrote:

On 9 Apr 2008, at 16:37, Jonathan R. wrote:

yet defined in environment.rb? Huh?

Where in environment.rb do you have that? ActiveRecord is only going
to be defined once the initialisation process has loaded ActiveRecord.
Any point after the Rails::Initializer.run … block should be fine.

Fred

Thanks.

It’s inside the Rails::Initializer.run block. This used to work. For
some reason it stopped working when I updated my ‘gem’ gem (still using
the same version of Rails, 1.2.1). But is this not supposed to be done
this way? I find lots of sample code on the web that references
ActiveRecord inside the Rails::Initializer.run block?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs