Skip to content
Advertisement

How to make where clause optional with ORM?

I’ve got a query:

This query includes user’s reviews

How to make user_reviews: { review_type: 'author_as_contractor' } clause optional?

Select user even if he has no reviews.

Advertisement

Answer

You can use eager_load and where like this for that:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement