Forum: Ruby on Rails uninitialized constant RenameIssuedCodes error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B148a9a418f647ed8d1358c17e64a2d8?d=identicon&s=25 Louise Rains (rainyglade)
on 2009-05-23 21:40
I have a series of migrations which I have used over the last 4 months
without any problems.  I have followed the pattern of deleting and
recreating the tables, doing the migrations and then loading fixtures.
This has all worked successfully until yesterday, when I started to get
an "uninitialized constat" error.

Here's the error and the stack trace:

c:\mick>rake db:migrate --trace
(in c:/mick)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
uninitialized constant RenameIssuedCodes
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependenci
es.rb:278:in `load_missing_constant'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependenci
es.rb:467:in `const_missing'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependenci
es.rb:479:in `const_missing'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/inflector.
rb:283:in `constantize'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/core_ext/s
tring/inflections.rb:143:in `constantize'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb
:456:in `migrations'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_a
dapters/mysql_adapter.rb:15:in `inject'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb
:440:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb
:440:in `inject'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb
:440:in `migrations'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb
:406:in `migrate'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb
:357:in `up'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb
:340:in `migrate'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/tasks/databases.rake:99
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `call'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `execute'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `execute'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in
`invoke_with_call_c
hain'
c:/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in
`invoke_with_call_c
hain'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in
`invoke_task'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in
`top_level'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in
`top_level'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in
`standard_exceptio
n_handling'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in
`top_level'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in
`standard_exceptio
n_handling'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31
c:/ruby/bin/rake:16:in `load'
c:/ruby/bin/rake:16

I have a model called issued_code.rb which looks like this:

class IssuedCode < ActiveRecord::Base
  belongs_to :CodeRequest
end

The migration 002_create_issued_codes.rb:

class CreateIssuedCodes < ActiveRecord::Migration
  def self.up
    create_table :issued_codes do |t|
      t.integer :code_request_id
      t.text :file_text
      t.datetime :date_issued

      t.timestamps
    end
  end

  def self.down
    drop_table :issued_codes
  end
end

I'm baffled - any ideas on how to fix this?

TIA
LG Rains
B148a9a418f647ed8d1358c17e64a2d8?d=identicon&s=25 Louise Rains (rainyglade)
on 2009-05-23 21:43
Never mind, I found the problem.  I had an empty migration called
xxx_rename_issued_codes.rb.  Don't know where it came from, but when I
deleted it, the migrations worked just fine.

LG
This topic is locked and can not be replied to.