Hey all, i''m rather new to rails and was curious if ActiveRecord implemented anything like is_active where the delete functions would just mark records as inactive, vs deleting rows. (similar to created_at, etc). I need a history of transactions, and this is how I would code in other languages. Any advice? Is there are smarter way to implement this? Thanks in advance! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 5/11/07, Philip Hallstrom <rails-SUcgGwS4C16SUMMaM/qcSw@public.gmane.org> wrote:> > > Hey all, i''m rather new to rails and was curious if ActiveRecord > > implemented anything like is_active where the delete functions would > > just mark records as inactive, vs deleting rows. (similar to created_at, > > etc). I need a history of transactions, and this is how I would code in > > other languages. Any advice? Is there are smarter way to implement this? > > http://agilewebdevelopment.com/plugins/acts_as_paranoid > > Make your Active Records "paranoid." Deleting them does not delete the > row, but set a deleted_at field. Find is overloaded to skip deleted > records.I''d say keep it more explicit and use the scope_out plugin: http://www.dcmanges.com/blog/21 class Foo < AR::Base scope_out :enabled, :conditions => ''disabled_at is null'' def enabled? disabled_at.nil? end def disabled? !enabled? end def disable update_attribute :disabled_at, Time.now.utc end end Foo.find_enabled(:all, :limit => 30, :offset => 60).each do |foo| end -- Rick Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Hey all, i''m rather new to rails and was curious if ActiveRecord > implemented anything like is_active where the delete functions would > just mark records as inactive, vs deleting rows. (similar to created_at, > etc). I need a history of transactions, and this is how I would code in > other languages. Any advice? Is there are smarter way to implement this?http://agilewebdevelopment.com/plugins/acts_as_paranoid Make your Active Records "paranoid." Deleting them does not delete the row, but set a deleted_at field. Find is overloaded to skip deleted records. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks for the links guys!! I''ll review both, and made a decision on which way to go. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---