0

I have a problem with using Class-Table-Inheritance gem. When I try check in console the correctness of inheritance console return this error:

NoMethodError: undefined method `set_primary_key' for Client (call 'Client.connection' to establish a connection):Class

I define primary key for Client, but there is still error.

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

end

Model Client

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

Part of migration file 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

Part of migration file CreateClients

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

How to resolve this problem?

Prezes Łukasz
  • 938
  • 1
  • 9
  • 30
  • 1
    This gem has no dev activity in the last 5 years. – BroiSatse Mar 02 '16 at 08:54
  • @BroiSatse Do you know any gem to implement class table inheritance? – Prezes Łukasz Mar 02 '16 at 08:55
  • 1
    You can have a look at dbview_cti: https://github.com/mvdamme/dbview_cti. It is actually so cool it creates database views for speed and glory. :) – BroiSatse Mar 02 '16 at 09:02
  • @BroiSatse I tried use this gem, but it's create properly view, not table in database... – Prezes Łukasz Mar 02 '16 at 09:04
  • Not sure what you mean here. You need to create class tables on your own, it will handle getting the data out of mutliple tables. What was your particular problem with it? – BroiSatse Mar 02 '16 at 09:06
  • @BroiSatse I want to imitate my entities diagram using code first. I would like to use class type inheritance, and I thought that this gem is the best way to do this. But now I feel confuse... – Prezes Łukasz Mar 02 '16 at 14:52

0 Answers0