Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rake aborted uninitialized constant "Computers"

I have a very annoying problem with my migrations.

First the Errormessage:

bundle exec rake db:migrate --trace
(in /home/myhomefolder/msdnaa)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
An error has occurred, all later migrations canceled:

uninitialized constant Computers

Now i have the assumption that an Update made by one of our admins is the reason why this happens every time. Even if there are no migrations at all!

What i've done (besides searching on Stack Overflow for a solution) is to grep every single file for "Computers". Of course there are some Files containing this word and i checked them for Syntax Errors and the usual Stuff like missing ":". Then i asked a workmate for some help (he is much more skilled with ruby than i am) and he hasn't a clue, everything looks right.

I'm using a slightly old Version of Ruby (1.8.7) and Rails (3.0.9), but i have no rights to do an update on our Server, so i have to deal with it. And yes i asked the admin to do an update to 1.9.x and 3.1.x, but that can't be the fault 'cause it worked fine last week. So it's one of those Errors where it SHOULD work, but it doesn't and i bet the solution is easy as drinking water, but i don't see it!

Any suggestions?

EDIT: Here ist the --trace:

/var/lib/gems/1.8/gems/activesupport-3.0.9/lib/active_support/inflector/meth               ods.rb:113:in `constantize'
/var/lib/gems/1.8/gems/activesupport-3.0.9/lib/active_support/inflector/meth               ods.rb:112:in `each'
/var/lib/gems/1.8/gems/activesupport-3.0.9/lib/active_support/inflector/meth               ods.rb:112:in `constantize'
/var/lib/gems/1.8/gems/activesupport-3.0.9/lib/active_support/core_ext/strin               g/inflections.rb:43:in `constantize'
/var/lib/gems/1.8/gems/activerecord-3.0.9/lib/active_record/migration.rb:407               :in `load_migration'
/var/lib/gems/1.8/gems/activerecord-3.0.9/lib/active_record/migration.rb:402               :in `migration'
/var/lib/gems/1.8/gems/activerecord-3.0.9/lib/active_record/migration.rb:397               :in `migrate'
/var/lib/gems/1.8/gems/activerecord-3.0.9/lib/active_record/migration.rb:539               :in `migrate'
/var/lib/gems/1.8/gems/activerecord-3.0.9/lib/active_record/migration.rb:615               :in `call'
/var/lib/gems/1.8/gems/activerecord-3.0.9/lib/active_record/migration.rb:615               :in `ddl_transaction'
/var/lib/gems/1.8/gems/activerecord-3.0.9/lib/active_record/migration.rb:538               :in `migrate'
/var/lib/gems/1.8/gems/activerecord-3.0.9/lib/active_record/migration.rb:525               :in `each'
/var/lib/gems/1.8/gems/activerecord-3.0.9/lib/active_record/migration.rb:525               :in `migrate'
/var/lib/gems/1.8/gems/activerecord-3.0.9/lib/active_record/migration.rb:435               :in `up'
/var/lib/gems/1.8/gems/activerecord-3.0.9/lib/active_record/migration.rb:417               :in `migrate'
/var/lib/gems/1.8/gems/activerecord-3.0.9/lib/active_record/railties/databas               es.rake:142
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:205:in `execute'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:158:in `invoke_with_call_               chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_               chain'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_tas               k'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:90:in `top_level'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:90:in `top_level'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_e               xception_handling'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:62:in `run'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_e               xception_handling'
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/var/lib/gems/1.8/gems/rake-0.9.2/bin/rake:32
/var/lib/gems/1.8/bin/rake:19:in `load'
/var/lib/gems/1.8/bin/rake:19
Tasks: TOP => db:migrate
like image 254
ProblemChild Avatar asked Feb 21 '12 09:02

ProblemChild


1 Answers

My guess is that you have just added a migration called something like 20120221123456_computers.rb, and within it, you have something like...

class SomeNameThatsNotComputers < ActiveRecord::Migration
  ...

When Rails executes a migration, it expects to execute the file, which defines the class, and then instantiate the class, and call #up or #down on that class instance. How does Rails know what class to instantiate? It's supposed to correspond with the part of the file name following the numeric prefix and underscore, so for a file name like 20120221123456_computers.rb, the class name must be Computers.

like image 116
Steve Jorgensen Avatar answered Nov 18 '22 03:11

Steve Jorgensen