我已经将一个Rails 2.3.14
项目转换为Rails 3.2.2
我在使用不直接从以下的表时遇到问题ActiveRecord::Base
我有一个定义如下的模型:
class PauaServiceTable < ActiveRecord::Base
def self.abstract_class?
true
end
..
..
end
我有很多课程都来自这个课程。例如:
class Lookup < PauaServiceTable
...
end
在 Railsconsole (3.3.2)
中,我可以实例化任何直接Activerecord::Base
继承自的表,但任何继承自的表都会PauaServiceTable
失败,并带有以下堆栈跟踪:
Loading development environment (Rails 3.2.2)
ruby-1.8.7-p334 :001 > l=Lookup.new
ActiveRecord::StatementInvalid: Mysql2::Error: Incorrect table name '': SHOW FULL FIELDS FROM ``
from /Users/george/.rvm/gems/ruby-1.8.7-p334@rails322/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `query'
from /Users/george/.rvm/gems/ruby-1.8.7-p334@rails322/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `execute'
from /Users/george/.rvm/gems/ruby-1.8.7-p334@rails322/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `log'
from /Users/george/.rvm/gems/ruby-1.8.7-p334@rails322/gems/activesupport-3.2.2/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /Users/george/.rvm/gems/ruby-1.8.7-p334@rails322/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
from /Users/george/.rvm/gems/ruby-1.8.7-p334@rails322/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `execute'
from /Users/george/.rvm/gems/ruby-1.8.7-p334@rails322/gems/activerecord-3.2.2/lib/active_record/connection_adapters/mysql2_adapter.rb:211:in `execute'
from /Users/george/.rvm/gems/ruby-1.8.7-p334@rails322/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:257:in `execute_and_free'
from /Users/george/.rvm/gems/ruby-1.8.7-p334@rails322/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:424:in `columns'
from /Users/george/.rvm/gems/ruby-1.8.7-p334@rails322/gems/activerecord-3.2.2/lib/active_record/connection_adapters/schema_cache.rb:12:in `initialize'
from /Users/george/.rvm/gems/ruby-1.8.7-p334@rails322/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:228:in `call'
from /Users/george/.rvm/gems/ruby-1.8.7-p334@rails322/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:228:in `default'
from /Users/george/.rvm/gems/ruby-1.8.7-p334@rails322/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:228:in `[]'
from /Users/george/.rvm/gems/ruby-1.8.7-p334@rails322/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:228:in `columns'
from /Users/george/.rvm/gems/ruby-1.8.7-p334@rails322/gems/activerecord-3.2.2/lib/active_record/model_schema.rb:243:in `column_defaults'
from /Users/george/.rvm/gems/ruby-1.8.7-p334@rails322/gems/activerecord-3.2.2/lib/active_record/base.rb:479:in `initialize'
from (irb):1:in `new'
from (irb):1ruby-1.8.7-p334 :002 >
此代码工作正常,Rails 2.3.14
但现在转换为3.2.2
.