I dont want to delete the records from my tables but just set a column is_deleted to true. What is the best (clean)way to implement this? Is there any way of defining a model which includes only a set of records which satisfy a certain conditions.eg a condition to include the records for which is_deleted is false some thing like this def User << ActiveRecord::Base :conditions=> "is_deleted=false" end Regards, Pankaj --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, You could override the destroy method in the controller: UsersController>> ApplicationController ... def destroy Car.find(params[:id]).is_deleted = true redirect_to :action => ''list'' end ... end Pablo.- On Jan 11, 2008 9:11 AM, pankaj <pankajbhageria-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I dont want to delete the records from my tables but just set a column > is_deleted to true. > What is the best (clean)way to implement this? > > Is there any way of defining a model which includes only a set of > records which satisfy a certain conditions.eg a condition to include > the records for which is_deleted is false > some thing like this > > def User << ActiveRecord::Base > :conditions=> "is_deleted=false" > end > Regards, > Pankaj > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
the acts_as_paranoid plugin does this. On Jan 11, 2008 6:47 AM, Pablo Iaria <iariap-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > You could override the destroy method in the controller: > > UsersController>> ApplicationController > ... > def destroy > Car.find(params[:id]).is_deleted = true > redirect_to :action => ''list'' > end > ... > end > > Pablo.- > > On Jan 11, 2008 9:11 AM, pankaj <pankajbhageria-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I dont want to delete the records from my tables but just set a column > > is_deleted to true. > > What is the best (clean)way to implement this? > > > > Is there any way of defining a model which includes only a set of > > records which satisfy a certain conditions.eg a condition to include > > the records for which is_deleted is false > > some thing like this > > > > def User << ActiveRecord::Base > > :conditions=> "is_deleted=false" > > end > > Regards, > > Pankaj > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---