Skip to content

vcastellm/rails-trash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trash

Simple trash for your models setting the delete_at to Time.now.utc.

Installing

Add it to your Gemfile:

gem 'trash', :git => 'https://github.com/fesplugas/rails-trash.git'

Usage

Add to your entries the deleted_at attribute:

add_column :entries, :deleted_at, :timestamp

And use it on your models.

class Post < ActiveRecord::Base
  has_trash

  default_scope where(:deleted_at => nil)
end

If you want to get the deleted entries:

>> Entry.deleted
=> [...]

If you want to restore a deleted entry:

>> Entry.deleted.first.restore
=> [...]

Copyright (c) 2011 Francesc Esplugas Marti, released under the MIT license

About

Trash for Rails models using scopes. (KISS)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages