You can use the concept of unidirectional inheritance in rails.
Since you have both Trains and Buses , both of which can be called Vehicle types, you can have the basic Vehicle model, and let both Train and Bus inherit from Vehicle as follows:
class Vehicle < ActiveRecord::Base; end class Train < Vehicle; end class Bus < Vehicle; end
And then your User class can have a one-to-many association with Cargo through Vehicle .
Similarly, if you call user.cargoes ( User as an instance of User ), the result should be all the loads of the specified user.
Hope this sheds light on this issue for you ...
source share