Adding automatic conditions to find method


Is there a way to add automatic condition to all active record find

I have an attribute in all my tables something like “effective_end_date”
so that I don’t delete records but I keep them by setting
effective_end_date so I want to put condition is all my find queries
effective_end_date Is null or effective_end_date > I don’t
want to type this for every single query so I was wondering if it’s
possible to automate it.



On 27 Mar., 07:20, Tam K. [email protected] wrote:

possible to automate it.
Yes, you can use default_scope:
It supports the same options as the find methods.

Best regards,
David K.

Thanks David…this is defenitaly the best solution but I realised that
it needs rails 2.3.2 which I’m currently not using! I will try to
upgrade but I’m worried I have to change lots of things. Do you know a
way to do it in previous versions of rails?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs