ActiveRecord::StatementInvalid in new action on scaffolding

I am trying to learn Rails by experimenting with it. Currently, I’m
trying on my laptop running Windows 7 (build 7000), with Ruby 1.8.6,
RubyGems 1.3.1, and Rails 2.3.2(.1). I of course had to get
sqlite3-ruby installed, which I did. I just created some scaffolding
with script/generate (which I had to do as ruby .\script\generate, as
I was in Windows PowerShell) then attempted to run the DB migrations.

PS C:\Users\Darren VanBuren\rails\blog> rake db:migrate
(in C:/Users/Darren VanBuren/rails/blog)
== CreatePosts: migrating

– create_table(:posts)
→ 0.0050s
== CreatePosts: migrated (0.0150s)

rake aborted!
Could not find table ‘posts’

Running with --trace presents:

PS C:\Users\Darren VanBuren\rails\blog> rake db:migrate --trace
(in C:/Users/Darren VanBuren/rails/blog)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
** Invoke db:schema:dump (first_time)
** Invoke environment
** Execute db:schema:dump
rake aborted!
Could not find table ‘posts’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite3_adapter.rb:29:in
table structure' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/object/misc.rb:39:in returning’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite3_adapter.rb:28:in
table structure' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:213:in colum
s’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/schema_dumper.rb:77:in
table' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/schema_dumper.rb:72:in tables’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/schema_dumper.rb:63:in
each' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/schema_dumper.rb:63:in tables’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/schema_dumper.rb:25:in
dump' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/schema_dumper.rb:19:in dump’
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/tasks/databases.rake:251
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/tasks/databases.rake:250:in
open' C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/tasks/databases.rake:250 C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in call’
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in execute' C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in each’
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in execute' C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in invoke_with_call_chain’
C:/Ruby/lib/ruby/1.8/monitor.rb:242:in synchronize' C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in invoke_with_call_chain’
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in invoke' C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/tasks/databases.rake:117 C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in call’
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:617:in execute' C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in each’
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in execute' C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in invoke_with_call_chain’
C:/Ruby/lib/ruby/1.8/monitor.rb:242:in synchronize' C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in invoke_with_call_chain’
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:564:in invoke' C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2027:in invoke_task’
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in
top_level' C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in each’
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in
top_level' C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in standard_exception_handling’
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1999:in
top_level' C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in run’
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in
standard_exception_handling' C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in run’
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/bin/rake:31
C:/Ruby/bin/rake:19:in `load’
C:/Ruby/bin/rake:19

I then looked at the table and found it to be there, and it had the
complete structure.
Having saw that, I figured I’ll give it a go. The index action on the
controller works just fine, but when I attempt to access the “new”
action, I get an equally frustrating message:

ActiveRecord::StatementInvalid in PostsController#new

Could not find table ‘posts’

RAILS_ROOT: C:/Users/Darren VanBuren/rails/blog
Application Trace | Framework Trace | Full Trace

C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite3_adapter.rb:29:in
table_structure' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/object/misc.rb:39:in returning’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite3_adapter.rb:28:in
table_structure' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite_adapter.rb:213:in columns’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1276:in
columns' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:3008:in attributes_from_column_definition_without_lock’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/locking/optimistic.rb:66:in
attributes_from_column_definition' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2435:in initialize’
C:/Users/Darren
VanBuren/rails/blog/app/controllers/posts_controller.rb:27:in new' C:/Users/Darren VanBuren/rails/blog/app/controllers/posts_controller.rb:27:in new’

This is particularly frustrating, because running a MySQLd seems
pointless for such a trivial Rails application. Am I making an obvious
mistake or is something really wrong?

Darren L. VanBuren

Hi,
I had the same problem! Try removing the “quote_table_name” call in
the file “C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
active_record/connection_adapters/sqlite3_adapter.rb” line 29 that did
it for me.

In short replace the line :
returning structure = @connection.table_info(quote_table_name
(table_name)) do
with :
returning structure = @connection.table_info(table_name) do

Math