Class-Table-Inheritance gemの使用に問題があります。コンソールで確認しようとすると、継承コンソールの正確性が次のエラーを返します。
NoMethodError: クライアントのメソッド `set_primary_key' が未定義です (接続を確立するには、'Client.connection' を呼び出します):Class
クライアントの主キーを定義しましたが、まだエラーがあります。
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
この問題を解決するにはどうすればよいですか?