Rake db:在Windows上迁移rails的错误

时间:2014-12-06 14:01:29

标签: ruby-on-rails devise

我刚刚开始学习rails并且创建了一个注册页面,我使用了" gem devise",当我运行rake db:migrate时,我得到以下错误



C:\Sites\code\omrails>rake db:migrate
== 20141206132117 DeviseCreateUsers: migrating ================================
-- create_table(:users)
   -> 0.0700s
-- add_index(:users, :email, {:unique=>true})
   -> 0.0010s
-- add_index(:users, :reset_password_token, {:unique=>true})
   -> 0.0010s
== 20141206132117 DeviseCreateUsers: migrated (0.0750s) =======================

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

wrong number of arguments(1 for 0)
Tasks: TOP => db:migrate
(See full trace by running task with --trace)




如果有人能帮助我克服这个错误。因为我无法继续前进。感谢。

使用--trace输出



Output after running with trace

C:\Sites\code\omrails> --trace
'--trace' is not recognized as an internal or external command,
operable program or batch file.

C:\Sites\code\omrails>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
== 20141206132117 DeviseCreateUsers: migrating ================================
-- create_table(:users)
   -> 0.0800s
-- add_index(:users, :email, {:unique=>true})
   -> 0.0030s
-- add_index(:users, :reset_password_token, {:unique=>true})
   -> 0.0020s
== 20141206132117 DeviseCreateUsers: migrated (0.0930s) =======================

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

wrong number of arguments(1 for 0)C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.
1/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_a
dapter.rb:271:in `initialize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/connection_adapters/abstract_adapter.rb:271:in `new'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/connection_adapters/abstract_adapter.rb:271:in `substitute_at'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/relation.rb:97:in `block in substitute_values'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/relation.rb:96:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/relation.rb:96:in `each_with_index'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/relation.rb:96:in `substitute_values'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/relation.rb:56:in `insert'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/persistence.rb:521:in `_create_record'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/counter_cache.rb:139:in `_create_record'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/attribute_methods/dirty.rb:122:in `_create_record'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/callbacks.rb:306:in `block in _create_record'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0.beta4/l
ib/active_support/callbacks.rb:88:in `call'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0.beta4/l
ib/active_support/callbacks.rb:88:in `_run_callbacks'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0.beta4/l
ib/active_support/callbacks.rb:734:in `_run_create_callbacks'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/callbacks.rb:306:in `_create_record'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/timestamp.rb:57:in `_create_record'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/persistence.rb:501:in `create_or_update'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/callbacks.rb:302:in `block in create_or_update'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0.beta4/l
ib/active_support/callbacks.rb:88:in `call'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0.beta4/l
ib/active_support/callbacks.rb:88:in `_run_callbacks'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0.beta4/l
ib/active_support/callbacks.rb:734:in `_run_save_callbacks'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/callbacks.rb:302:in `create_or_update'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/persistence.rb:142:in `save!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/validations.rb:42:in `save!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/attribute_methods/dirty.rb:29:in `save!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/transactions.rb:289:in `block in save!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/transactions.rb:345:in `block in with_transaction_returning_stat
us'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/connection_adapters/abstract/database_statements.rb:211:in `tran
saction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/transactions.rb:218:in `transaction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/transactions.rb:342:in `with_transaction_returning_status'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/transactions.rb:289:in `save!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/persistence.rb:51:in `create!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:1015:in `record_version_state_after_migrating'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:985:in `block in execute_migration_in_transaction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:1030:in `block in ddl_transaction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/connection_adapters/abstract/database_statements.rb:213:in `bloc
k in transaction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_t
ransaction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/connection_adapters/abstract/database_statements.rb:213:in `tran
saction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/transactions.rb:218:in `transaction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:1030:in `ddl_transaction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:983:in `execute_migration_in_transaction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:945:in `block in migrate'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:941:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:941:in `migrate'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:813:in `up'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/migration.rb:791:in `migrate'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/tasks/database_tasks.rb:137:in `migrate'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0.beta4/li
b/active_record/railties/databases.rake:44:in `block (2 levels) in <top (require
d)>'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.4.0/lib/rake/task.r
b:240:in `call'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.4.0/lib/rake/task.r
b:240:in `block in execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.4.0/lib/rake/task.r
b:235:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.4.0/lib/rake/task.r
b:235:in `execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.4.0/lib/rake/task.r
b:179:in `block in invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.4.0/lib/rake/task.r
b:172:in `invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.4.0/lib/rake/task.r
b:165:in `invoke'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.4.0/lib/rake/applic
ation.rb:156:in `invoke_task'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.4.0/lib/rake/applic
ation.rb:112:in `block (2 levels) in top_level'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.4.0/lib/rake/applic
ation.rb:112:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.4.0/lib/rake/applic
ation.rb:112:in `block in top_level'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.4.0/lib/rake/applic
ation.rb:121:in `run_with_threads'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.4.0/lib/rake/applic
ation.rb:106:in `top_level'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.4.0/lib/rake/applic
ation.rb:84:in `block in run'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.4.0/lib/rake/applic
ation.rb:182:in `standard_exception_handling'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.4.0/lib/rake/applic
ation.rb:79:in `run'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.4.0/bin/rake:33:in
`<top (required)>'
C:/RailsInstaller/Ruby1.9.3/bin/rake:23:in `load'
C:/RailsInstaller/Ruby1.9.3/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate

C:\Sites\code\omrails>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:1)

看起来你正在使用Rails 4.2.0.beta4。 ActiveRecord将需要arel gem。将'arel'添加到您的Gemfile中。

gem 'arel', '6.0.0.beta2'

然后运行:bundle update arel

然后bundle install

答案 1 :(得分:0)

Inbetween rails版本bug。更新你的rails gem,在你的项目中更改它的版本,删除Gemfile.lock并进行bundle install,这对我有用。 在这里找到它:https://medium.com/@bitadj/rake-db-migrate-fails-on-rails-v-4-2-0-betax-36ceae38da44