Ruby Rails 3 rake db:迁移失败,出现“rake中止!”!无法将SQLite3::语句转换为数组的

Ruby Rails 3 rake db:迁移失败,出现“rake中止!”!无法将SQLite3::语句转换为数组的,ruby,ruby-on-rails-3,rake,dbmigrate,Ruby,Ruby On Rails 3,Rake,Dbmigrate,我正在学习RubyonRails3教程,在尝试迁移数据库时遇到了一个错误。即使在运行db:migrate之前执行db:drop操作,也会出现“无法将SQLite3::语句转换为数组”错误。我尝试过更新rake并从我的Gemfile中删除rspec,但这两种方法都不适用于我 rake db:migrate -t ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment

我正在学习RubyonRails3教程,在尝试迁移数据库时遇到了一个错误。即使在运行db:migrate之前执行db:drop操作,也会出现“无法将SQLite3::语句转换为数组”错误。我尝试过更新rake并从我的Gemfile中删除rspec,但这两种方法都不适用于我

rake db:migrate -t
** Invoke db:migrate (first_time)
** Invoke environment (first_time)   
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env 
** Execute db:load_config
** Execute db:migrate
   rake aborted!
   can't convert SQLite3::Statement into Array
   /Library/Ruby/Gems/1.8/gems/activerecord-3.1.1/lib/active_record/result.rb:30:in `zip'
   /Library/Ruby/Gems/1.8/gems/activerecord-3.1.1/lib/active_record/result.rb:30:in    `hash_rows'
   /Library/Ruby/Gems/1.8/gems/activerecord-3.1.1/lib/active_record/result.rb:29:in `map'
   /Library/Ruby/Gems/1.8/gems/activerecord-3.1.1/lib/active_record/result.rb:29:in `hash_rows'
   /Library/Ruby/Gems/1.8/gems/activerecord-3.1.1/lib/active_record/result.rb:20:in `each'
   /Library/Ruby/Gems/1.8/gems/activerecord- 3.1.1/lib/active_record/connection_adapters/sqlite_adapter.rb:315:in `map'
   /Library/Ruby/Gems/1.8/gems/activerecord-3.1.1/lib/active_record/connection_adapters/sqlite_adapter.rb:315:in `tables'
   /Library/Ruby/Gems/1.8/gems/activerecord-3.1.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:25:in  `table_exists?'
   /Library/Ruby/Gems/1.8/gems/activerecord-3.1.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:417:in `initialize_schema_migrations_table'
   /Library/Ruby/Gems/1.8/gems/activerecord-3.1.1/lib/active_record/migration.rb:634:in `initialize'
   /Library/Ruby/Gems/1.8/gems/activerecord-3.1.1/lib/active_record/migration.rb:549:in `new'
   /Library/Ruby/Gems/1.8/gems/activerecord-3.1.1/lib/active_record/migration.rb:549:in `up'
   /Library/Ruby/Gems/1.8/gems/activerecord-3.1.1/lib/active_record/migration.rb:530:in `migrate'
   /Library/Ruby/Gems/1.8/gems/activerecord-3.1.1/lib/active_record/railties/databases.rake:161
   /Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
   /Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `execute'
   /Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
   /Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
   /Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
     /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
   /Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
   /Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
   /Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
   /Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
   /Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
   /Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
   /Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
   /Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
   /Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `run'
   /Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
   /Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
   /Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/bin/rake:33
   /usr/bin/rake:19:in `load'
   /usr/bin/rake:19
   Tasks: TOP => db:migrate
我使用的宝石有:

Using rake (0.9.2.2) 
Using multi_json (1.0.4) 
Using activesupport (3.1.1) 
Using builder (3.0.0) 
Using i18n (0.6.0) 
Using activemodel (3.1.1) 
Using erubis (2.7.0) 
Using rack (1.3.5) 
Using rack-cache (1.1) 
Using rack-mount (0.8.3) 
Using rack-test (0.6.1) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.0.3) 
Using actionpack (3.1.1) 
Using mime-types (1.17.2) 
Using polyglot (0.3.3) 
Using treetop (1.4.10) 
Using mail (2.3.0) 
Using actionmailer (3.1.1) 
Using arel (2.2.1) 
Using tzinfo (0.3.31) 
Using activerecord (3.1.1) 
Using activeresource (3.1.1) 
Using bundler (1.0.21) 
Using coffee-script-source (1.1.3) 
Using execjs (1.2.12) 
Using coffee-script (2.2.0) 
Using rack-ssl (1.3.2) 
Using json (1.6.3) 
Using rdoc (3.12) 
Using thor (0.14.6) 
Using railties (3.1.1) 
Using coffee-rails (3.1.1) 
Using jquery-rails (1.0.19) 
Using nokogiri (1.5.0) 
Using rails (3.1.1) 
Using sass (3.1.12) 
Using sass-rails (3.1.5) 
Using sqlite3 (1.3.5) 
Using sqlite3-ruby (1.2.5) 
Using uglifier (1.2.0) 
Using webrat (0.7.1)
真的对这个错误感到困惑吗

迁移文件:

class CreateUsers < ActiveRecord::Migration
  def change
    create_table :users do |t|
      t.string :name
      t.string :email

      t.timestamps
    end
  end
end


class CreateItems < ActiveRecord::Migration
  def change
    create_table :items do |t|
      t.string :title
      t.string :description
      t.double :price
      t.string :category

      t.timestamps
    end
  end
end
使用ruby 1.9.2而不是1.8.7会导致:

    rake aborted!
    NoMethodError: undefined method `to_a' for #<SQLite3::Statement:0x007f9404b73b18>:
          SELECT name
          FROM sqlite_master
          WHERE type = 'table' AND NOT name = 'sqlite_sequence'

    Tasks: TOP => db:migrate

通过修改Gemfile以使用以下内容解决了此问题:

gem 'sqlite3', '1.3.5', :require => 'sqlite3'
而不是

gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'

教程中提供了哪些

您可以添加迁移文件吗?