gpt4 book ai didi

mysql - Rails Mysql 适配器尝试查询没有支持表的抽象模型类

转载 作者:可可西里 更新时间:2023-11-01 07:35:28 25 4
gpt4 key购买 nike

我有一个模型类“Abtest”,它继承自一个没有支持表的抽象基类“ModBase”。当调用 Abtest.new 时,即使在 ModBase 类中我有“self.abstract_class = true”,我也会收到以下错误。我做错了什么?

class ModBase < ActiveRecord::Base
self.abstract_class = true

class Abtest < ModBase

ActiveRecord::StatementInvalid (Mysql::Error: Table 'mydb.mod_bases' doesn't exist: SHOW FIELDS FROM `mod_bases`):
activerecord (3.1.0) lib/active_record/connection_adapters/mysql_adapter.rb:435:in `query'
activerecord (3.1.0) lib/active_record/connection_adapters/mysql_adapter.rb:435:in `execute'
activerecord (3.1.0) lib/active_record/connection_adapters/abstract_adapter.rb:244:in `log'
activesupport (3.1.0) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activerecord (3.1.0) lib/active_record/connection_adapters/abstract_adapter.rb:239:in `log'
activerecord (3.1.0) lib/active_record/connection_adapters/mysql_adapter.rb:435:in `execute'
activerecord (3.1.0) lib/active_record/connection_adapters/mysql_adapter.rb:636:in `columns'
activerecord (3.1.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `initialize'
activerecord (3.1.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:185:in `with_connection'
activerecord (3.1.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:92:in `initialize'
activerecord (3.1.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:112:in `call'
activerecord (3.1.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:112:in `default'
activerecord (3.1.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:112:in `[]'
activerecord (3.1.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:112:in `initialize'
activerecord (3.1.0) lib/active_record/base.rb:717:in `call'
activerecord (3.1.0) lib/active_record/base.rb:717:in `default'
activerecord (3.1.0) lib/active_record/base.rb:717:in `[]'
activerecord (3.1.0) lib/active_record/base.rb:717:in `column_defaults'
activerecord (3.1.0) lib/active_record/persistence.rb:327:in `attributes_from_column_definition'
activerecord (3.1.0) lib/active_record/locking/optimistic.rb:69:in `attributes_from_column_definition'
activerecord (3.1.0) lib/active_record/base.rb:1544:in `initialize'
app/models/abtest.rb:89:in `new'

最佳答案

这是 3.1.0 中的一个 Rails 错误。 https://github.com/rails/rails/issues/558

我已经升级到 3.1.11,错误再也没有发生。

关于mysql - Rails Mysql 适配器尝试查询没有支持表的抽象模型类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15455687/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com