Module: Shared::BiologicalAssociations::ClassMethods
- Defined in:
- app/models/concerns/shared/biological_associations.rb
Overview
scope :with_biological_associations, ->
joins("LEFT OUTER JOIN biological_associations tnr1 ON otus.id = tnr1.biological_association_subject_id AND tnr1.biological_association_object_type = 'Otu'").
joins("LEFT OUTER JOIN biological_associations tnr2 ON otus.id = tnr2.biological_association_object_id AND tnr2.biological_association_object_type = 'Otu'").
where('tnr1.biological_association_object_id IS NOT NULL OR tnr2.biological_association_object_id IS NOT NULL')
Instance Method Summary collapse
Instance Method Details
#with_biological_relationship_id(biological_relationship_ids) ⇒ Object
44 45 46 47 48 49 |
# File 'app/models/concerns/shared/biological_associations.rb', line 44 def with_biological_relationship_id(biological_relationship_ids) a = joins(:biological_associations).where(biological_associations: {biological_relationship_id: biological_relationship_ids}) b = joins(:related_biological_associations).where(biological_associations: {biological_relationship_id: biological_relationship_ids}) from("((#{a.to_sql}) UNION (#{b.to_sql})) as #{base_class.table_name}") end |