ActiveRecord :: StatementInvalid即使我在rails 2.3.18中添加表也是如此

时间:2015-04-15 14:22:26

标签: ruby-on-rails rails-migrations

我正在开发维护项目,其中包含rails版本' 2.3.18' rvm使用ree-1.8.7-2012.02 [x86_64] 。 当我运行rake db:在bundle install和rake db:create之后迁移时,我收到以下错误:

rake aborted!
Could not find table 'comments'

(See full trace by running task with --trace)

为此,我手动创建注释表:

ruby script/generate migration CreateComments commentable_type:string commentable_id:integer body:text member_id:integer created_at:datettime

为此,我收到错误:

/root/Desktop/Projects/community/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:29:in `table_structure': Could not find table 'comments' (ActiveRecord::StatementInvalid)
    from /root/Desktop/Projects/community/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:28:in `tap'
    from /root/Desktop/Projects/community/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:28:in `table_structure'
    from /root/Desktop/Projects/community/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:228:in `columns'
    from /root/Desktop/Projects/community/lib/extensions/active_record.rb:8:in `columns'
    from /root/Desktop/Projects/community/vendor/rails/activerecord/lib/active_record/base.rb:1318:in `column_names'
    from /root/Desktop/Projects/community/vendor/gems/acts-as-taggable-on-2.0.4/lib/acts_as_taggable_on/acts_as_taggable_on/cache.rb:5:in `included'
    from /root/Desktop/Projects/community/vendor/gems/acts-as-taggable-on-2.0.4/lib/acts_as_taggable_on/acts_as_taggable_on/collection.rb:28:in `any?'
    from /root/Desktop/Projects/community/vendor/gems/acts-as-taggable-on-2.0.4/lib/acts_as_taggable_on/acts_as_taggable_on/cache.rb:5:in `each'
    from /root/Desktop/Projects/community/vendor/gems/acts-as-taggable-on-2.0.4/lib/acts_as_taggable_on/acts_as_taggable_on/cache.rb:5:in `any?'
    from /root/Desktop/Projects/community/vendor/gems/acts-as-taggable-on-2.0.4/lib/acts_as_taggable_on/acts_as_taggable_on/cache.rb:5:in `included'
    from /root/Desktop/Projects/community/vendor/gems/acts-as-taggable-on-2.0.4/lib/acts_as_taggable_on/acts_as_taggable_on.rb:46:in `include'
    from /root/Desktop/Projects/community/vendor/gems/acts-as-taggable-on-2.0.4/lib/acts_as_taggable_on/acts_as_taggable_on.rb:46:in `acts_as_taggable_on'
    from /root/Desktop/Projects/community/vendor/gems/acts-as-taggable-on-2.0.4/lib/acts_as_taggable_on/acts_as_taggable_on.rb:36:in `class_eval'
    from /root/Desktop/Projects/community/vendor/gems/acts-as-taggable-on-2.0.4/lib/acts_as_taggable_on/acts_as_taggable_on.rb:36:in `acts_as_taggable_on'
    from /root/Desktop/Projects/community/vendor/gems/acts-as-taggable-on-2.0.4/lib/acts_as_taggable_on/acts_as_taggable_on.rb:15:in `acts_as_taggable'
    from /root/Desktop/Projects/community/app/models/comment.rb:58
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/dependencies.rb:406:in `load_without_new_constant_marking'
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/dependencies.rb:406:in `load_file'
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/dependencies.rb:547:in `new_constants_in'
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/dependencies.rb:405:in `load_file'
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/dependencies.rb:285:in `require_or_load'
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/dependencies.rb:451:in `load_missing_constant'
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/dependencies.rb:106:in `const_missing'
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/dependencies.rb:118:in `const_missing'
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/inflector.rb:364:in `constantize'
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/inflector.rb:363:in `each'
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/inflector.rb:363:in `constantize'
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb:162:in `constantize'
    from /root/Desktop/Projects/community/vendor/rails/activerecord/lib/active_record/observer.rb:157:in `observed_class'
    from /root/Desktop/Projects/community/vendor/rails/activerecord/lib/active_record/observer.rb:183:in `observed_classes'
    from /root/Desktop/Projects/community/vendor/rails/activerecord/lib/active_record/observer.rb:166:in `initialize'
    from /usr/local/rvm/rubies/ree-1.8.7-2012.02/lib/ruby/1.8/singleton.rb:94:in `new'
    from /usr/local/rvm/rubies/ree-1.8.7-2012.02/lib/ruby/1.8/singleton.rb:94:in `instance'
    from /root/Desktop/Projects/community/vendor/rails/activerecord/lib/active_record/observer.rb:38:in `instantiate_observers'
    from /root/Desktop/Projects/community/vendor/rails/activerecord/lib/active_record/observer.rb:36:in `each'
    from /root/Desktop/Projects/community/vendor/rails/activerecord/lib/active_record/observer.rb:36:in `instantiate_observers'
    from /root/Desktop/Projects/community/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:15:in `define_dispatcher_callbacks'
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/callbacks.rb:182:in `call'
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/callbacks.rb:182:in `evaluate_method'
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/callbacks.rb:166:in `call'
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in `run'
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in `each'
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in `send'
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in `run'
    from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/callbacks.rb:276:in `run_callbacks'
    from /root/Desktop/Projects/community/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:51:in `send'
    from /root/Desktop/Projects/community/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:51:in `run_prepare_callbacks'
    from /root/Desktop/Projects/community/vendor/rails/railties/lib/initializer.rb:631:in `prepare_dispatcher'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:185:in `process'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:113:in `send'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:113:in `run'
    from /root/Desktop/Projects/community/config/environment.rb:15
    from /usr/local/rvm/rubies/ree-1.8.7-2012.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
    from /usr/local/rvm/rubies/ree-1.8.7-2012.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
    from /root/Desktop/Projects/community/vendor/rails/railties/lib/commands/generate.rb:1
    from /usr/local/rvm/rubies/ree-1.8.7-2012.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
    from /usr/local/rvm/rubies/ree-1.8.7-2012.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
    from script/generate:3

请帮帮我。

2 个答案:

答案 0 :(得分:1)

你能告诉我们你的模特评论吗?它可能与它有关,正如您在堆栈跟踪中看到的那样:

from /root/Desktop/Projects/community/vendor/gems/acts-as-taggable-on-2.0.4/lib/acts_as_taggable_on/acts_as_taggable_on.rb:15:in `acts_as_taggable'
from /root/Desktop/Projects/community/app/models/comment.rb:58
from /root/Desktop/Projects/community/vendor/rails/activesupport/lib/active_support/dependencies.rb:406:in `load_without_new_constant_marking'

答案 1 :(得分:0)

created_at:datetime拼写错误..它是created_at:datetime