Admin Model:
has_many :transport_vehicles_as_driver, class_name: "Transport::Vehicle",as: :driver
has_many :transport_vehicles_as_attendant, class_name: "Transport::Vehicle",as: :attendant
relation_1 = Admin.where(category: "TRANSPORT").left_outer_joins(:transport_vehicles_as_attendant).where("transport_vehicles.reference_code LIKE ?", "%#{keyword}%").distinct
relation_2 = Admin.where(category: "TRANSPORT").left_outer_joins(:transport_vehicles_as_driver).where("transport_vehicles.reference_code LIKE ?", "%#{keyword}%").distinct
relation_1.or(relation_2) produces the following error:
ArgumentError (Relation passed to #or must be structurally compatible. Incompatible values: [:left_outer_joins])
I have checked the following close stackoverflow sources : Relation passed to #or must be structurally compatible. Incompatible values: [:references]