Skip to content

Commit

Permalink
reformatting readme
Browse files Browse the repository at this point in the history
  • Loading branch information
janxious committed Mar 3, 2012
1 parent 655fe53 commit 1f0593b
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
#ActsAsArchival
# ActsAsArchival

Plugin for atomically archiving model records in activerecord models.

We had the problem that acts_as_paranoid and similar plugins/gems always work on a record by record basis and made it very difficult to restore records atomically (or archive them, for that matter).
We had the problem that acts_as_paranoid and similar plugins/gems
always work on a record by record basis and made it very difficult to
restore records atomically (or archive them, for that matter).

Because the archive and unarchive methods are in transactions, and every archival record involved gets the same archive number upon archiving, you can easily restore or remove an entire set of records without having to worry about partial deletion or restoration.
Because the archive and unarchive methods are in transactions, and
every archival record involved gets the same archive number upon
archiving, you can easily restore or remove an entire set of records
without having to worry about partial deletion or restoration.

Additionally, other plugins generally screw with how `destroy`/`delete` work. We don't because we actually want to be able to destroy records.
Additionally, other plugins generally screw with how
`destroy`/`delete` work. We don't because we actually want to be able
to destroy records.

##Install
## Install

Rails 3:

Expand All @@ -18,13 +25,15 @@ Rails 2:

`script/plugin install http://github.com/expectedbehavior/acts_as_archival.git -r rails2`

Any models you want to be archival should have the columns `archive_number`(String) and `archived_at` (DateTime).
Any models you want to be archival should have the columns
`archive_number`(String) and `archived_at` (DateTime).

i.e. `script/generate migration AddAAAToPost archive_number:string archived_at:datetime`

Any dependent-destroy objects connected to an AAA model will be archived with its parent.
Any dependent-destroy objects connected to an AAA model will be
archived with its parent.

##Example
## Example

``` ruby
class Hole < ActiveRecord::Base
Expand Down Expand Up @@ -56,14 +65,21 @@ end
>> Hole.unarchived.size # => 1
```

##Caveats
## Caveats

1. This will only work on associations that are dependent destroy. It should be trival to change that or make it optional.
1. It will only work for Rails 2.2 and up, because we are using `named_scope`/`scope`. You can check out permanent records for a way to conditionally add the functionality to older Rails installations.
1. This will only work on associations that are dependent destroy. It
should be trival to change that or make it optional.
1. It will only work for Rails 2.2 and up, because we are using
`named_scope`/`scope`. You can check out permanent records for a way
to conditionally add the functionality to older Rails installations.
1. This will only work (well) on databases with transactions (mysql,
postgres, etc.).

##Testing
## Testing

Because this plugin makes use of transactions we're testing it on MySQL instead of the more convenient sqlite. Running the tests should be as easy as
Because this plugin makes use of transactions we're testing it on
MySQL instead of the more convenient sqlite. Running the tests should
be as easy as:

``` bash
cd ./test/aaa_test_app/
Expand All @@ -73,13 +89,13 @@ cd ../.. # back in the AAA root
rake
```

##Thanks
## Thanks

ActsAsParanoid and PermanentRecords were both inspirations for this
http://github.com/technoweenie/acts_as_paranoid
http://github.com/fastestforward/permanent_records

##Contributors
## Contributors

* Joel Meador
* Michael Kuehl
Expand Down

0 comments on commit 1f0593b

Please sign in to comment.