README.md in effective_logging-1.6.0 vs README.md in effective_logging-1.7.0
- old
+ new
@@ -14,10 +14,11 @@
Automatically logs any email sent by the application, any successful user login via Devise, and all page views.
Has an effective_datatables driven admin interface to display and search/sort/filter all logs.
+Audits changes and performs Trash restore functionality for Active Record objects.
## Getting Started
Add to your Gemfile:
@@ -206,18 +207,10 @@
class Post < ActiveRecord::Base
log_changes
end
```
-And to your controller:
-
-```ruby
-class ApplicationController < ActionController::Base
- before_action :set_log_changes_user
-end
-```
-
Then to see the log for this resource, on any view:
```erb
<%= render_datatable(@post.log_changes_datatable) %>
```
@@ -250,9 +243,39 @@
ActionController::Base.helpers.number_to_currency(value)
elsif ['percentage'].include?(attribute)
ActionController::Base.helpers.number_to_percentage(value)
end
end
+```
+
+### Trash & Restore
+
+This gem provides a fully functional Trash implementation that can be
+used to delete and restore active record objects in any rails application.
+
+Add to your model:
+
+```ruby
+class Post < ActiveRecord::Base
+ acts_as_trashable
+end
+```
+
+The `acts_as_trashable` mixin sets up `before_destroy` hook and copies the now-deleted attributes to an `Effective::Log` object.
+
+Visit `/trash`, or `/admin/trash` to restore them.
+
+The above routes require the following, user specific, permissions:
+
+```ruby
+can :restore, Effective::Log, user_id: user.id
+```
+
+and for admin:
+
+```ruby
+can :restore, Effective::Log
+can :admin, :effective_logging
```
### Logging From JavaScript
First, require the javascript in your application.js: