Reputation: 61
I was working through Ruby on Rails 3 tutorial when I experienced an error while trying to migrate my db. The 'can't convert SQLite3::Statement into Array' error appears even if I do a db:drop before running db:migrate. I've tried updating rake and deleting rspec from my Gemfile but neither worked for me.
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
the gems i'm using are:
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)
Really confused about this error
Migration files:
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
Using ruby 1.9.2 instead of 1.8.7 resulted in this:
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
Upvotes: 1
Views: 2086
Reputation: 61
the issue was resolved by modifying Gemfile to use:
gem 'sqlite3', '1.3.5', :require => 'sqlite3'
instead of
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
which was offered in the tutorial
Upvotes: 3