0

我在使用Class-Table-Inheritance gem 时遇到问题。当我尝试签入控制台时,继承控制台的正确性返回此错误:

NoMethodError:客户端的未定义方法“set_primary_key”(调用“Client.connection”建立连接):类

我为客户端定义了主键,但仍然有错误。

class Person < ActiveRecord::Base
  acts_as_superclass
 self.table_name = 'people'

end

模型客户端

class Client < ActiveRecord::Base
   inherits_from :person
   self.primary_key = "person_id"
end

部分迁移文件 CreatePeople

create_table :people do |t|
  t.string :pesel, null: false
  t.string :first_name, null: false
  t.string :last_name, null: false
  t.string :email, null: false
  t.date :date_of_birth, null: false
  t.timestamps null: false
end

迁移文件 CreateClients 的一部分

create_table :clients, :inherits => :person do |t|
end

如何解决这个问题?

4

0 回答 0