Forum: Ruby on Rails lost in an ActiveRecord::StatementInvalid

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7223c62b7310e164eb79c740188abbda?d=identicon&s=25 Xavier Noria (Guest)
on 2005-12-17 22:25
(Received via mailing list)
I have an error I don't know how to debug. I am adding the login
suport in Depot (the example in the RoR book) and
LoginController#add_user throws ActiveRecord::StatementInvalid in an
innocent /login/add_user GET request.

The trace goes down to a call to SQLiteAdapter#table_structure, and
the source code suggests what's happening is that "PRAGMA
table_structure(#{table_name})" is returning empty metadata for some
reason:

     def table_structure(table_name)
       returning structure = execute("PRAGMA table_info(#
{table_name})") do
         raise ActiveRecord::StatementInvalid if structure.empty?
       end
     end

Now, the sqlite client returns this:

     sqlite> pragma table_info("users");
     cid         name        type        notnull     dflt_value  pk
     ----------  ----------  ----------  ----------  ----------
----------
     0           id          integer     0                       1
     1           name        varchar(10  99                      0
     2           hashed_pas  char(40)    0                       0

And the model class is this:

   require 'digest/sha1'

   class User < ActiveRecord::Base
     attr_accessor :password
     attr_accessible :name, :password

     validates_uniqueness_of :name
     validates_presence_of :name, :password

     def before_create
       self.hashed_password = User.hash_password(self.password)
     end

     def after_create
       @password = nil
     end

     private
     def self.hash_password(password)
       Digest::SHA1.hexdigest(password)
     end
   end

Any hints?

-- fxn

PS: The full stack trace is here: http://rafb.net/paste/results/
dFbMab24.html
This topic is locked and can not be replied to.