Virtually deleting rows from tables

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

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.-

the acts_as_paranoid plugin does this.

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