Rails inheritance

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: ID PK Brand ...

And some child classes

Printer: ID_EQUIPMENT PK and FK ...

Computers: ID_EQUIPMENT PK and FK ...

Phones: ID_EQUIPMENT PK and FK ...

Among others

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

I've been bogged down in this for a while

    
asked by anonymous 18.05.2018 / 20:53

1 answer

0

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

-> If you need to set the PK your Equipment would be equivalent to class Document (shown at the end of the section)

- > if you did not need it would be class Physician .

    
12.06.2018 / 22:34