Look at acts_as_paranoid. I use it for a similar, but different reason,
but it may help you. Basically, if you add acts_as_paranoid to your
category model, when you destroy a category, it actually sets a column
deleted_at to the current time. Acts_as_paranoid overrides the find and
count methods to ignore anything that has deleted_at not null. However,
it has accessor methods that allow you to return all categories
including those with the deleted_at column set. I heard someone say that
the author of this plugin may not be supporting it in the future,
however, I am using it with no issues. YMMV
http://wiki.rubyonrails.org/rails/pages/Acts+As+Paranoid+Plugin
Bala Paranj wrote:> class Event < ActiveRecord::
> Base
> has_many :categories
> end
>
> If I delete a category, it affects the events that were created before. How
can make sure that event can still display it''s old category name? TIA.
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---