尝试在我的 psql 数据库上运行 rake db:migrate 时出现“参数数量错误(给定 1,预期为 0)”错误。这个提问者遇到了同样的问题,但是将我的 Gemfile 锁定“到 gem 'arel'、'6.0.0.beta2'”并使用 rails 版本 4.2.0.beta4 并没有解决问题,尽管我能够捆绑并且绝对使用这些版本。任何帮助将非常感激!
这是完整的跟踪
rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
== 20161104230329 Createmytable: migrating ==================================
-- create_table(:mytable)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
wrong number of arguments (given 1, expected 0)
/home/ubuntu/workspace/mydb_api/db/migrate/20161104230329_create_mytable.rb:4:in `block in change'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/schema_statements.rb:199:in `create_table'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:655:in `block in method_missing'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:625:in `block in say_with_time'
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/benchmark.rb:293:in `measure'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:625:in `say_with_time'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:645:in `method_missing'
/home/ubuntu/workspace/mydb_api/db/migrate/20161104230329_create_mytable.rb:3:in `change'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:599:in `exec_migration'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:583:in `block (2 levels) in migrate'
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/benchmark.rb:293:in `measure'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:582:in `block in migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:581:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:758:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:984:in `block in execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `block in ddl_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `ddl_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:983:in `execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:945:in `block in migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `each'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:813:in `up'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:791:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:248:in `block in execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:243:in `each'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:243:in `execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:180:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:173:in `invoke'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:152:in `invoke_task'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:108:in `each'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:108:in `block in top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:117:in `run_with_threads'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:102:in `top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:80:in `block in run'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:178:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:77:in `run'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/bin/rake:23:in `load'
/usr/local/rvm/gems/ruby-2.3.0/bin/rake:23:in `<main>'
ArgumentError: wrong number of arguments (given 1, expected 0)
/home/ubuntu/workspace/mydb_api/db/migrate/20161104230329_create_mytable.rb:4:in `block in change'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/schema_statements.rb:199:in `create_table'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:655:in `block in method_missing'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:625:in `block in say_with_time'
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/benchmark.rb:293:in `measure'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:625:in `say_with_time'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:645:in `method_missing'
/home/ubuntu/workspace/mydb_api/db/migrate/20161104230329_create_mytable.rb:3:in `change'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:599:in `exec_migration'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:583:in `block (2 levels) in migrate'
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/benchmark.rb:293:in `measure'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:582:in `block in migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:581:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:758:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:984:in `block in execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `block in ddl_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `ddl_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:983:in `execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:945:in `block in migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `each'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:813:in `up'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:791:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:248:in `block in execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:243:in `each'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:243:in `execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:180:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:173:in `invoke'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:152:in `invoke_task'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:108:in `each'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:108:in `block in top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:117:in `run_with_threads'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:102:in `top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:80:in `block in run'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:178:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:77:in `run'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/bin/rake:23:in `load'
/usr/local/rvm/gems/ruby-2.3.0/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate
这是文件 20161104230329_create_mytable.rb
class CreateTables < ActiveRecord::Migration
def change
create_table :mytable do |t|
t.name :string
t.param1 :integer
t.param2 :integer
t.param3 :integer
t.timestamps null: false
end
end
end