1

我是 Rails 新手,想使用 rails 迁移脚本向我的开发数据库添加一个表。跑步后rails db:migrate,我得到了NameError: wrong constant name 2040[MyMigrationClassName].

我以为我使用了保留的类名,所以我更改了迁移脚本中的名称 + 与之关联的视图、模型和转换器,但同样的错误。

为什么会这样?提前感谢您的帮助。

这是错误:

$ 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

我使用 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

4

1 回答 1

1

原来迁移文件名db/migrate/20210312_2040_create_converter.rb是错误的。

为了可读性而放置的时间戳之间的下划线最终通过附加数字来弄乱常量名称,因此Name Error: wrong constant name.

我也:

  • 复数的文件名,因为删除下划线后,我得到了另一个要求复数的错误
  • :created at之后删除了参数t.timestamps

最后,文件名变成db/migrate/202103122040_create_converters.rb了,迁移顺利进行。

于 2021-03-25T06:02:54.487 回答