vendredi 10 juin 2022

Ruby - IF or OR condition on a JOINS statement

How can I specify a OR condition on a joins statement? Basically I don't want the joins for where(:tenant_id => User.current_tenant. If I try OR condition I get the following error.

I get the following error.

Relation passed to #or must be structurally compatible. Incompatible values: [:joins] [catalog/explorer]

  scope :public_service_templates,                  ->         { joins(:miq_user_roles).where(miq_user_roles: { settings: nil}).or(where(:tenant_id => User.current_tenant)) }

Aucun commentaire:

Enregistrer un commentaire