Rails 6 - db:migrate NameError: wrong constant name
Rails 6 - db:migrate NameError: wrong constant name
我是 Rails 的新手,想使用 rails 迁移脚本将 table 添加到我的开发数据库中。在 运行 rails db:migrate
之后,我得到了 NameError: wrong constant name 2040[MyMigrationClassName]
.
我以为我使用了保留的 class 名称,所以我更改了迁移脚本中的名称 + 与之关联的视图、模型和转换器,但同样的错误。
为什么会这样?
预先感谢您的帮助。
这是错误:
$ rails db:migrate
rails aborted!
NameError: wrong constant name 2040CreateConverter
/home/ubuntu/MyApp/bin/rails:5:in `<top (required)>'
/home/ubuntu/MyApp/bin/spring:10:in `block in <top (required)>'
/home/ubuntu/Myapp/bin/spring:7:in `<top (required)>'
Caused by:
NameError: wrong constant name 2040CreateConverter
/home/ubuntu/MyApp/bin/rails:5:in `<top (required)>'
/home/ubuntu/MyApp/bin/spring:10:in `block in <top (required)>'
/home/ubuntu/MyApp/bin/spring:7:in `<top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
这是迁移脚本:
class CreateConverters < ActiveRecord::Migration[6.1]
def change
create_table :converters do |t|
t.string :banks
t.binary :files
t.binary :results
t.timestamps :created_at
end
end
end
我已经有了模型 Converter
、控制器 ConverterController
和 converter/*.html.erb
视图,它们将与 table.
相关联
我使用 Rails 6.1.3、Ruby 3.0 和 postgreSQL 作为数据库。我在 Ubuntu 20.04 LTS。
这是详细的错误跟踪:
$ rails db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Execute db:migrate
rails aborted!
NameError: wrong constant name 2040CreateConverter
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3/lib/active_support/inflector/methods.rb:274:in `const_get'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3/lib/active_support/inflector/methods.rb:274:in `constantize'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3/lib/active_support/core_ext/string/inflections.rb:74:in `constantize'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1046:in `load_migration'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1041:in `migration'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1037:in `disable_ddl_transaction'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1387:in `use_transaction?'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1334:in `rescue in execute_migration_in_transaction'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1322:in `execute_migration_in_transaction'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1302:in `each'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1302:in `migrate_without_lock'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1251:in `block in migrate'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1401:in `block in with_advisory_lock'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1416:in `block in with_advisory_lock_connection'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:462:in `with_connection'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1416:in `with_advisory_lock_connection'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1397:in `with_advisory_lock'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1251:in `migrate'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1086:in `up'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1061:in `migrate'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/tasks/database_tasks.rb:237:in `migrate'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/railties/databases.rake:92:in `block (3 levels) in <main>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/railties/databases.rake:90:in `each'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/railties/databases.rake:90:in `block (2 levels) in <main>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `block in execute'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `each'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `execute'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `synchronize'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `invoke_with_call_chain'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:188:in `invoke'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:160:in `invoke_task'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `each'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `block in top_level'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:125:in `run_with_threads'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:110:in `top_level'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/rake_module.rb:59:in `with_application'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/command.rb:52:in `invoke'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/commands.rb:18:in `<main>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/ubuntu/MyApp/bin/rails:5:in `<top (required)>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `load'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `call'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client/command.rb:7:in `call'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client.rb:30:in `run'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/bin/spring:49:in `<top (required)>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `load'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `<top (required)>'
<internal:/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
<internal:/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
/home/ubuntu/MyApp/bin/spring:10:in `block in <top (required)>'
<internal:kernel>:90:in `tap'
/home/ubuntu/MyApp/bin/spring:7:in `<top (required)>'
bin/rails:2:in `load'
bin/rails:2:in `<main>'
Caused by:
NameError: wrong constant name 2040CreateConverter
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3/lib/active_support/inflector/methods.rb:274:in `const_get'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3/lib/active_support/inflector/methods.rb:274:in `constantize'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3/lib/active_support/core_ext/string/inflections.rb:74:in `constantize'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1046:in `load_migration'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1041:in `migration'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1037:in `disable_ddl_transaction'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1387:in `use_transaction?'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1379:in `ddl_transaction'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1328:in `execute_migration_in_transaction'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1302:in `each'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1302:in `migrate_without_lock'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1251:in `block in migrate'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1401:in `block in with_advisory_lock'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1416:in `block in with_advisory_lock_connection'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:462:in `with_connection'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1416:in `with_advisory_lock_connection'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1397:in `with_advisory_lock'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1251:in `migrate'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1086:in `up'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1061:in `migrate'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/tasks/database_tasks.rb:237:in `migrate'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/railties/databases.rake:92:in `block (3 levels) in <main>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/railties/databases.rake:90:in `each'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/railties/databases.rake:90:in `block (2 levels) in <main>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `block in execute'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `each'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `execute'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `synchronize'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `invoke_with_call_chain'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:188:in `invoke'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:160:in `invoke_task'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `each'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `block in top_level'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:125:in `run_with_threads'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:110:in `top_level'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/rake_module.rb:59:in `with_application'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/command.rb:52:in `invoke'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/commands.rb:18:in `<main>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/ubuntu/MyApp/bin/rails:5:in `<top (required)>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `load'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `call'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client/command.rb:7:in `call'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client.rb:30:in `run'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/bin/spring:49:in `<top (required)>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `load'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `<top (required)>'
<internal:/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
<internal:/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
/home/ubuntu/MyApp/bin/spring:10:in `block in <top (required)>'
<internal:kernel>:90:in `tap'
/home/ubuntu/MyApp/bin/spring:7:in `<top (required)>'
bin/rails:2:in `load'
bin/rails:2:in `<main>'
Tasks: TOP => db:migrate
原来迁移文件名 db/migrate/20210312_2040_create_converter.rb
是错误的。
为了便于阅读而设置的时间戳之间的下划线最终通过附加数字弄乱了常量名称,因此 Name Error: wrong constant name
。
我也:
- 将文件名复数化,因为在删除下划线后,我得到另一个要求复数化的错误
- 删除了
t.timestamps
之后的参数 :created at
。
最后文件名变成了db/migrate/202103122040_create_converters.rb
迁移运行顺利
我是 Rails 的新手,想使用 rails 迁移脚本将 table 添加到我的开发数据库中。在 运行 rails db:migrate
之后,我得到了 NameError: wrong constant name 2040[MyMigrationClassName]
.
我以为我使用了保留的 class 名称,所以我更改了迁移脚本中的名称 + 与之关联的视图、模型和转换器,但同样的错误。
为什么会这样? 预先感谢您的帮助。
这是错误:
$ rails db:migrate
rails aborted!
NameError: wrong constant name 2040CreateConverter
/home/ubuntu/MyApp/bin/rails:5:in `<top (required)>'
/home/ubuntu/MyApp/bin/spring:10:in `block in <top (required)>'
/home/ubuntu/Myapp/bin/spring:7:in `<top (required)>'
Caused by:
NameError: wrong constant name 2040CreateConverter
/home/ubuntu/MyApp/bin/rails:5:in `<top (required)>'
/home/ubuntu/MyApp/bin/spring:10:in `block in <top (required)>'
/home/ubuntu/MyApp/bin/spring:7:in `<top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
这是迁移脚本:
class CreateConverters < ActiveRecord::Migration[6.1]
def change
create_table :converters do |t|
t.string :banks
t.binary :files
t.binary :results
t.timestamps :created_at
end
end
end
我已经有了模型 Converter
、控制器 ConverterController
和 converter/*.html.erb
视图,它们将与 table.
我使用 Rails 6.1.3、Ruby 3.0 和 postgreSQL 作为数据库。我在 Ubuntu 20.04 LTS。
这是详细的错误跟踪:
$ rails db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Execute db:migrate
rails aborted!
NameError: wrong constant name 2040CreateConverter
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3/lib/active_support/inflector/methods.rb:274:in `const_get'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3/lib/active_support/inflector/methods.rb:274:in `constantize'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3/lib/active_support/core_ext/string/inflections.rb:74:in `constantize'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1046:in `load_migration'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1041:in `migration'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1037:in `disable_ddl_transaction'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1387:in `use_transaction?'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1334:in `rescue in execute_migration_in_transaction'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1322:in `execute_migration_in_transaction'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1302:in `each'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1302:in `migrate_without_lock'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1251:in `block in migrate'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1401:in `block in with_advisory_lock'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1416:in `block in with_advisory_lock_connection'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:462:in `with_connection'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1416:in `with_advisory_lock_connection'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1397:in `with_advisory_lock'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1251:in `migrate'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1086:in `up'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1061:in `migrate'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/tasks/database_tasks.rb:237:in `migrate'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/railties/databases.rake:92:in `block (3 levels) in <main>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/railties/databases.rake:90:in `each'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/railties/databases.rake:90:in `block (2 levels) in <main>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `block in execute'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `each'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `execute'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `synchronize'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `invoke_with_call_chain'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:188:in `invoke'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:160:in `invoke_task'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `each'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `block in top_level'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:125:in `run_with_threads'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:110:in `top_level'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/rake_module.rb:59:in `with_application'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/command.rb:52:in `invoke'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/commands.rb:18:in `<main>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/ubuntu/MyApp/bin/rails:5:in `<top (required)>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `load'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `call'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client/command.rb:7:in `call'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client.rb:30:in `run'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/bin/spring:49:in `<top (required)>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `load'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `<top (required)>'
<internal:/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
<internal:/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
/home/ubuntu/MyApp/bin/spring:10:in `block in <top (required)>'
<internal:kernel>:90:in `tap'
/home/ubuntu/MyApp/bin/spring:7:in `<top (required)>'
bin/rails:2:in `load'
bin/rails:2:in `<main>'
Caused by:
NameError: wrong constant name 2040CreateConverter
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3/lib/active_support/inflector/methods.rb:274:in `const_get'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3/lib/active_support/inflector/methods.rb:274:in `constantize'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3/lib/active_support/core_ext/string/inflections.rb:74:in `constantize'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1046:in `load_migration'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1041:in `migration'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1037:in `disable_ddl_transaction'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1387:in `use_transaction?'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1379:in `ddl_transaction'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1328:in `execute_migration_in_transaction'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1302:in `each'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1302:in `migrate_without_lock'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1251:in `block in migrate'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1401:in `block in with_advisory_lock'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1416:in `block in with_advisory_lock_connection'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:462:in `with_connection'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1416:in `with_advisory_lock_connection'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1397:in `with_advisory_lock'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1251:in `migrate'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1086:in `up'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/migration.rb:1061:in `migrate'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/tasks/database_tasks.rb:237:in `migrate'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/railties/databases.rake:92:in `block (3 levels) in <main>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/railties/databases.rake:90:in `each'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3/lib/active_record/railties/databases.rake:90:in `block (2 levels) in <main>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `block in execute'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `each'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:281:in `execute'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `synchronize'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:199:in `invoke_with_call_chain'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/task.rb:188:in `invoke'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:160:in `invoke_task'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `each'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:116:in `block in top_level'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:125:in `run_with_threads'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:110:in `top_level'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/lib/rake/rake_module.rb:59:in `with_application'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/command.rb:52:in `invoke'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3/lib/rails/commands.rb:18:in `<main>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/ubuntu/MyApp/bin/rails:5:in `<top (required)>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `load'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `call'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client/command.rb:7:in `call'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client.rb:30:in `run'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/bin/spring:49:in `<top (required)>'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `load'
/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `<top (required)>'
<internal:/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
<internal:/home/ubuntu/.rbenv/versions/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
/home/ubuntu/MyApp/bin/spring:10:in `block in <top (required)>'
<internal:kernel>:90:in `tap'
/home/ubuntu/MyApp/bin/spring:7:in `<top (required)>'
bin/rails:2:in `load'
bin/rails:2:in `<main>'
Tasks: TOP => db:migrate
原来迁移文件名 db/migrate/20210312_2040_create_converter.rb
是错误的。
为了便于阅读而设置的时间戳之间的下划线最终通过附加数字弄乱了常量名称,因此 Name Error: wrong constant name
。
我也:
- 将文件名复数化,因为在删除下划线后,我得到另一个要求复数化的错误
- 删除了
t.timestamps
之后的参数:created at
。
最后文件名变成了db/migrate/202103122040_create_converters.rb
迁移运行顺利