[Rails] uninitialized constant when trying to migrate files

28 views
Skip to first unread message

Kevin Ng

unread,
May 5, 2010, 2:36:57 AM5/5/10
to rubyonra...@googlegroups.com
Hi,

i am having this problem:

kevinngsw$ rake db:migrate --trace
(in /Users/kevinngsw/Documents/Programming/*******)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
An error has occurred, this and all later migrations canceled:

uninitialized constant CreateUrls
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:443:in
`load_missing_constant'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in
`const_missing'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in
`const_missing'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:361:in
`constantize'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:360:in
`each'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:360:in
`constantize'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/string/inflections.rb:162:in
`constantize'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:374:in
`load_migration'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:369:in
`migration'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:365:in
`migrate'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:486:in
`migrate'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:560:in
`call'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:560:in
`ddl_transaction'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in
`transaction'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:182:in
`transaction'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:560:in
`ddl_transaction'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:485:in
`migrate'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:472:in
`each'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:472:in
`migrate'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:400:in
`up'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:383:in
`migrate'
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/databases.rake:116
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
`execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
`execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in
`invoke_with_call_chain'
/usr/local/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
`invoke_with_call_chain'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in
`invoke_task'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
`top_level'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
`top_level'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
`standard_exception_handling'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in
`top_level'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
`standard_exception_handling'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19






this is the migration file:

class CreateURLs < ActiveRecord::Migration
def self.up
create_table :urls do |t|
t.string :label
t.string :url

t.timestamps
end
end

def self.down
drop_table :urls
end
end



this is the model file:

class URL < ActiveRecord::Base
belongs_to :contact_person
end




any help is appreciated. Thanks!!
--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

MaD

unread,
May 5, 2010, 3:57:44 AM5/5/10
to Ruby on Rails: Talk
whats the name of your file? looking at the class it should be named
*_create_u_r_ls.rb. if it is called *_create_urls.rb then your class
should be CreateUrls. smae with your model. try Url instead of URL.

Frederick Cheung

unread,
May 5, 2010, 4:00:53 AM5/5/10
to Ruby on Rails: Talk


On May 5, 7:36 am, Kevin Ng <li...@ruby-forum.com> wrote:

> this is the migration file:
>
> class CreateURLs < ActiveRecord::Migration

Assuming the file is some_number_create_urls.rb Rails is expecting the
migration class to be CreateUrls (similarly rails will expect to find
a model class called Url in url.rb)

Fred
Reply all
Reply to author
Forward
0 new messages