兼容性问题? rake db:migrate - 参数数量错误(1 代表 0)
Posted
技术标签:
【中文标题】兼容性问题? rake db:migrate - 参数数量错误(1 代表 0)【英文标题】:Compatibility issue? rake db:migrate - wrong number of arguments (1 for 0) 【发布时间】:2015-01-25 04:48:08 【问题描述】:我正在尝试运行一个简单的迁移,但出现此错误。我认为这是某种兼容性错误。我该如何修复它以及如何避免将来出现兼容性问题?
Migration: `class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :nume
t.string :email
t.string :localitate
t.timestamps
end
end
end
___________________
宝石文件
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0.beta4'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.0.beta1'
# Use Uglifier as compressor for javascript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jQuery as the JavaScript library
gem 'jquery-rails', '~> 4.0.0.beta2'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0.0.beta4'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :jruby]
___________
错误:
参数数量错误(1 代表 0)C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0
.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_
适配器.rb:271:in initialize'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/connection_adapters/abstract_adapter.rb:271:in
new'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/connection_adapters/abstract_adapter.rb:271:in substitute_at'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/relation.rb:97:in
block 在替代值'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/relation.rb:96:in each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/relation.rb:96:in
each_with_index'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/relation.rb:96:in substitute_values'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/relation.rb:56:in
insert'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/persistence.rb:521:in _create_record'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/counter_cache.rb:139:in
_create_record'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/attribute_methods/dirty.rb:122:in _create_record'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/callbacks.rb:306:in
block in _create_record'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta4/l
ib/active_support/callbacks.rb:88:in call'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta4/l
ib/active_support/callbacks.rb:88:in
_run_callbacks'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta4/l
ib/active_support/callbacks.rb:734:in _run_create_callbacks'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/callbacks.rb:306:in
_create_record'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/timestamp.rb:57:in _create_record'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/persistence.rb:501:in
create_or_update'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/callbacks.rb:302:in block in create_or_update'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta4/l
ib/active_support/callbacks.rb:88:in
call'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta4/l
ib/active_support/callbacks.rb:88:in _run_callbacks'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta4/l
ib/active_support/callbacks.rb:734:in
_run_save_callbacks'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/callbacks.rb:302:in create_or_update'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/persistence.rb:142:in
save!'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/validations.rb:42:in save!'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/attribute_methods/dirty.rb:29:in
save!'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/transactions.rb:289:in block in save!'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/transactions.rb:345:in
block in with_transaction_returning_stat
我们'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/connection_adapters/abstract/database_statements.rb:211:in tran
saction'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/transactions.rb:218:in
transaction'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/transactions.rb:342:in with_transaction_returning_status'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/transactions.rb:289:in
save!'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/persistence.rb:51:in create!'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:1015:in
record_version_state_after_migrating'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:985:in block in execute_migration_in_transaction'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:1030:in
block in ddl_transaction'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/connection_adapters/abstract/database_statements.rb:213:in bloc
k in transaction'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/connection_adapters/abstract/transaction.rb:188:in
within_new_t
赎罪
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/connection_adapters/abstract/database_statements.rb:213:in tran
saction'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/transactions.rb:218:in
transaction'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:1030:in ddl_transaction'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:983:in
execute_migration_in_transaction'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:945:in block in migrate'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:941:in
each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:941:in migrate'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:813:in
up'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:791:in migrate'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/tasks/database_tasks.rb:137:in
migrate'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta4/li
b/active_record/railties/databases.rake:44:in block (2 levels) in <top (require
d)>'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.0/lib/rake/task.r
b:240:in
call'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.0/lib/rake/task.r
b:240:in block in execute'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.0/lib/rake/task.r
b:235:in
each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.0/lib/rake/task.r
b:235:in execute'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.0/lib/rake/task.r
b:179:in
block in invoke_with_call_chain'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/monitor.rb:211:in mon_synchronize'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.0/lib/rake/task.r
b:172:in
invoke_with_call_chain'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.0/lib/rake/task.r
b:165:in invoke'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.0/lib/rake/applic
ation.rb:156:in
invoke_task'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.0/lib/rake/applic
ation.rb:112:in block (2 levels) in top_level'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.0/lib/rake/applic
ation.rb:112:in
each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.0/lib/rake/applic
ation.rb:112:in block in top_level'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.0/lib/rake/applic
ation.rb:121:in
run_with_threads'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.0/lib/rake/applic
ation.rb:106:in top_level'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.0/lib/rake/applic
ation.rb:84:in
block in run'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.0/lib/rake/applic
ation.rb:182:in standard_exception_handling'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.0/lib/rake/applic
ation.rb:79:in
run'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.0/bin/rake:33:in
<top (required)>'
C:/RailsInstaller/Ruby2.0.0/bin/rake:23:in
load'
C:/RailsInstaller/Ruby2.0.0/bin/rake:23:in `'
任务:TOP => db:migrate
【问题讨论】:
Can't migrate database after scaffold. Section 2.2 Ruby on Rails Tutorial Michael Hartl. 的可能重复项 我没有使用脚手架 请仔细阅读链接,这是一个rails错误,我今天强制关闭3个这样的问题。 谢谢。我很困惑。我什至没有“arel”宝石。 【参考方案1】:答案在这里:Can't migrate database after scaffold. Section 2.2 Ruby on Rails Tutorial Michael Hartl
您需要按照那里的说明安装 arel gem。
【讨论】:
以上是关于兼容性问题? rake db:migrate - 参数数量错误(1 代表 0)的主要内容,如果未能解决你的问题,请参考以下文章
markdown rake db:reset,rake db:migrate:resetの违い
如何运行 db:migrate 从另一个带参数的 rake 任务?