For every table in my app there is a corresponding deleted_.* table. I
would like to be able to copy a record to its corresponding deleted_.*
table. How might I achieve this?
If I have to have models for a deleted record, could I use some
metaprogramming magic to create these models? How would I do that if so?
I thought of doing deleted tables because I had already thought of
having
an attribute to mark a record as active, but figured I would have to
write
an exclusion clause every time.
Would there be a way to do this without having to write exclusion
clauses
for every query?
I thought of doing deleted tables because I had already thought of having
an attribute to mark a record as active, but figured I would have to
write
an exclusion clause every time.
Would there be a way to do this without having to write exclusion clauses
for every query?
acts_as_paranoid simply adds a deleted_at flag, it doesn’t move records to a
separate table.
It does a little more than simply that…
Something like acts_as_archive is a better equivalent.
The requirement to move them to another table was because the OP
didn’t know how to “flag” records in the same table as deleted and
have them auto-magically ignored by finders, etc.
If the requirement is to archive them (which isn’t the same as
softly deleting), along with the hassle of managing two sets of
tables… then acts_as_archived could be ideal.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.