Class Table Inheritance in Rails 3

后端 未结 4 404
无人共我
无人共我 2021-02-05 16:04

I\'m currently working on a Rails 3 application that looks like it might need to use Class Table Inheritance for a couple of models.

A simplified example of what\'s goin

4条回答
  •  独厮守ぢ
    2021-02-05 16:31

    why not using Single Table Inheritance? for example:

    class Person < ActiveRecord::Base
       # some common code here
    end
    
    class Driver < Person
       # Driver code
    end
    
    class Passenger < Person
       # Passenger code
    end
    

    in this way you'll have a common class Person, plus two specific classes derived from it

提交回复
热议问题