Inheritance in Rails

Asked

Viewed 89 times

1

I’m starting in the area, I have the following scenario in my back end done in Rails: I want to implement a parent class:

Equipment: PK ID Brand ...

And some child classes

Printer: ID_EQUIPAMENTO PK and FK ...

Computers: ID_EQUIPAMENTO PK and FK ...

Telephones: ID_EQUIPAMENTO PK and FK ...

Among other things

But I have 2 problems, the first is how to define the primary key of the parent class to be the primary key of the child classes. The other is how to implement this in the controller and routes.

I’ve been stuck in this for a while

1 answer

0


This site can help you, item 2.5 "The has_one :through Association" seems to be what you need.

->if you need to define your PK Equipment would be equivalent to class Document (presented at the end of the)

-> if you didn’t need class Physician even.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.