Re: [Rails] NoMethodError with rake db:migrate

94 views
Skip to first unread message

Colin Law

unread,
Sep 19, 2012, 11:12:14 AM9/19/12
to rubyonra...@googlegroups.com
On 18 September 2012 04:00, jose ramirez <a306...@gmail.com> wrote:
> Hi! First of all, this is my first application on Rails, and i'm stuck at a
> migration. i created a demo app (the demo_app from michael hartl's tutorial)
> as usual: rails new demo_app, rails generate scaffold User name:string
> email:string, and when i do rake db:migrate, this stack appears:
>
> 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
> rake aborted!
> NoMethodError: undefined method `to_a' for #<SQLite3::Statement:0x9d6a2dc>:
> SELECT name
> FROM sqlite_master
> WHERE type = 'table' AND NOT name = 'sqlite_sequence'
> AND name = "schema_migrations"
> ....
>
> This is the Gemfile:
>
> source 'https://rubygems.org'
>
> gem 'rails', '3.2.8'
>
> # Bundle edge Rails instead:
> # gem 'rails', :git => 'git://github.com/rails/rails.git'
>
> gem 'sqlite3'
> gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'

Are those the versions of rails (3.2.8) and sqlite3-ruby that the
tutorial expects? I don't know but I suspect that a later version of
sqlite3-ruby might fix it. Googling for the error message finds this
for example
http://stackoverflow.com/questions/8604360/rails-3-rake-dbmigrate-fails-with-a-rake-aborted-cant-convert-sqlite3state

Colin

>
> # Gems used only for assets and not required
> # in production environments by default.
> group :assets do
> gem 'sass-rails', '~> 3.2.3'
> gem 'coffee-rails', '~> 3.2.1'
>
> # See https://github.com/sstephenson/execjs#readme for more supported
> runtimes
> # gem 'therubyracer', :platforms => :ruby
>
> gem 'uglifier', '>= 1.0.3'
> end
>
> gem 'jquery-rails'
>
> # To use ActiveModel has_secure_password
> # gem 'bcrypt-ruby', '~> 3.0.0'
>
> # To use Jbuilder templates for JSON
> # gem 'jbuilder'
>
> # Use unicorn as the app server
> # gem 'unicorn'
>
> # Deploy with Capistrano
> # gem 'capistrano'
>
> # To use debugger
> # gem 'debugger'
>
> Any pointer to something i missed, or something wrong, will be highly
> appreciated. If you need any additional info in order to help, please ask,
> :)a
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-ta...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/mK9VVljoF2AJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Avi

unread,
Sep 20, 2012, 7:15:35 AM9/20/12
to rubyonra...@googlegroups.com


On Tuesday, September 18, 2012 8:30:54 AM UTC+5:30, jose ramirez wrote:
Hi! First of all, this is my first application on Rails, and i'm stuck at a migration. i created a demo app (the demo_app from michael hartl's tutorial) as usual: rails new demo_app, rails generate scaffold User name:string email:string, and when i do rake db:migrate, this stack appears:

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
rake aborted!
NoMethodError: undefined method `to_a' for #<SQLite3::Statement:0x9d6a2dc>:           SELECT name
          FROM sqlite_master
          WHERE type = 'table' AND NOT name = 'sqlite_sequence'
 AND name = "schema_migrations"
/var/lib/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/sqlite_adapter.rb:248:in `block in exec_query'
/var/lib/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/var/lib/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/var/lib/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/var/lib/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/sqlite_adapter.rb:242:in `exec_query'
/var/lib/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/sqlite_adapter.rb:335:in `tables'
/var/lib/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/sqlite_adapter.rb:341:in `table_exists?'
/var/lib/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/schema_statements.rb:425:in `initialize_schema_migrations_table'
/var/lib/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/migration.rb:663:in `initialize'
/var/lib/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/migration.rb:570:in `new'
/var/lib/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/migration.rb:570:in `up'
/var/lib/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/migration.rb:551:in `migrate'
/var/lib/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:153:in `block (2 levels) in <top (required)>'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19:in `<main>'
Tasks: TOP => db:migrate


This is the Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.8'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

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

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

You need to uncomment the rubyracer to make it work.
Hope this helps.
Reply all
Reply to author
Forward
0 new messages