Is there any way to force a where statement to be included in every SELECT-statement I do with Active Record? I'm using Rails 4.
For example: If I call:
Product.where(name: 'Fishing rod')
Then I want Rails to generate a SQL query like the following:
SELECT * FROM products WHERE products.client_id = 1 AND (name = 'Fishing rod')
where products.client_id = 1
is the forced where statement. All other conditions I define via where or other ORM-methods (like find
or whatever) should be included in the statement aswell.
Is there a possibility to define such forced condition?