I have an ActiveRecord model and the way it is setup, I never delete anything. Instead, I have a boolean column which is true if the record is deleted and false otherwise. I perform several .where queries on this model. I want a nice way to automatically append the condition, “:deleted => 0”, to all my .where calls I make so that I never retrieve deleted records.
My initial instinct was to extend the ‘where’ method for ActiveRecord, but it seems that there is no where method.
What would be the best way to achieve the above functionality in the most object-oriented way?
Thanks.
Sounds like you want to set the
default_scope:So something like this: