Skip to content

Commit 3e9a184

Browse files
bivanalharcysjonathan
authored andcommitted
chore(README): update README
1 parent b75dac5 commit 3e9a184

File tree

1 file changed

+39
-27
lines changed

1 file changed

+39
-27
lines changed

README.md

+39-27
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,46 @@
22

33
## Overview
44

5-
Userstamp extends `ActiveRecord::Base` to add automatic updating of `creator`, `updater`, and
5+
Userstamp extends `ActiveRecord::Base` to add automatic updating of `creator`, `updater`, and
66
`deleter` attributes. It is based loosely on `ActiveRecord::Timestamp`.
77

88
Two class methods (`model_stamper` and `stampable`) are implemented in this gem. The `model_stamper`
99
method is used in models that are responsible for creating, updating, or deleting other objects.
10-
Typically this would be the `User` model of your application. The `stampable` method is used in
10+
Typically this would be the `User` model of your application. The `stampable` method is used in
1111
models that are subject to being created, updated, or deleted by stampers.
1212

1313
## Forkception
1414

1515
This is a fork of:
1616

17-
- the [magiclabs-userstamp](https://github.com/magiclabs/userstamp) gem
18-
- which is a fork of [Michael Grosser's](https://github.com/grosser)
19-
[userstamp gem] (https://github.com/grosser/userstamp)
20-
- which is a fork of the original [userstamp plugin](https://github.com/delynn/userstamp) by
21-
[delynn](https://github.com/delynn)
17+
- the [magiclabs-userstamp](https://github.com/magiclabs/userstamp) gem
18+
- which is a fork of [Michael Grosser's](https://github.com/grosser)
19+
[userstamp gem] (https://github.com/grosser/userstamp)
20+
- which is a fork of the original [userstamp plugin](https://github.com/delynn/userstamp) by
21+
[delynn](https://github.com/delynn)
2222

2323
In addition to these, I have cherry picked ideas and changes from the following forks:
2424

25-
- [simplificator](https://github.com/simplificator/userstamp)
26-
- [akm](https://github.com/akm/magic_userstamp)
27-
- [konvenit](https://github.com/konvenit/userstamp)
25+
- [simplificator](https://github.com/simplificator/userstamp)
26+
- [akm](https://github.com/akm/magic_userstamp)
27+
- [konvenit](https://github.com/konvenit/userstamp)
2828

29-
Finally, this gem only supports Ruby 2.0 and above. Yes, you really should upgrade to a supported
30-
version of Ruby. This gem is tested only on Rails 4.2; but it should work with Rails 4+.
29+
Finally, this gem only supports Ruby 3.0 and 3.1. Yes, you really should upgrade to a supported
30+
version of Ruby. This gem is tested only on Rails 6 - 7; thus far, we have successfully tested it
31+
to be compatible with Rails 6.0, 6.1, 7.0, and 7.1
3132

3233
## Features
34+
3335
### Soft-deletes
36+
3437
The reason for this is because the original userstamp plugin does not support databases utilising
3538
soft deletes. They are not tested explicitly within this gem, but it is expected to work with the
3639
following gems:
3740

38-
- [acts_as_paranoid](https://github.com/ActsAsParanoid/acts_as_paranoid)
39-
- [paranoia](https://github.com/radar/paranoia)
41+
- [acts_as_paranoid](https://github.com/ActsAsParanoid/acts_as_paranoid)
42+
- [paranoia](https://github.com/radar/paranoia)
4043

41-
The `stampable` method has been modified to allow additional arguments to be passed to the
44+
The `stampable` method has been modified to allow additional arguments to be passed to the
4245
creator/updater relations. This allows declarations like:
4346

4447
```ruby
@@ -51,16 +54,18 @@ to result in a `belongs_to` relation which looks like:
5154
belongs_to :creator, class_name: '::User', foreign_key: :created_by, with_deleted: true
5255
```
5356

54-
Do create a ticket if it is broken, with a pull-request if possible.
57+
Do create a ticket if it is broken, with a pull-request if possible.
5558

5659
### Customisable column names/types
60+
5761
While examining the userstamp gem's network on Github, it was noticed that quite a few forks were
5862
made to allow customisability in the name and type of the column with the database migration.
5963

6064
This gem now supports customised column names. See the [usage](#usage) section on the
6165
configuration options supported.
6266

6367
### Saving before validation
68+
6469
This fork includes changes to perform model stamping before validation. This allows models to
6570
enforce the presence of stamp attributes:
6671

@@ -73,7 +78,8 @@ Furthermore, the `creator` attribute is set only if the value is blank allowing
7378
override.
7479

7580
## Usage
76-
Assume that we are building a blog application, with User and Post objects. Add the following
81+
82+
Assume that we are building a blog application, with User and Post objects. Add the following
7783
to the application's Gemfile:
7884

7985
```ruby
@@ -135,9 +141,10 @@ Declare the stamper on the User model:
135141
If your stamper is called `User`, that's it; you're done.
136142

137143
## Customisation
144+
138145
The association which is created on each of the `creator_id`, `updater_id`, and `deleter_id` can
139146
be customised. Also, the stamper used by each class can also be customised. For this purpose, the
140-
`ActiveRecord::Base.stampable` method can be used:
147+
`ActiveRecord::Base.stampable` method can be used:
141148

142149
```ruby
143150
class Post < ActiveRecord::Base
@@ -150,8 +157,10 @@ It also allows you to specify the name of the stamper for the class being declar
150157
arguments are passed to the `belongs_to` declaration.
151158

152159
## Upgrading
160+
153161
### Upgrading from delynn's 1.x/2.x with `compatibility_mode`
154-
The major difference between 1.x and 2.x is the naming of the columns. This version of the gem
162+
163+
The major difference between 1.x and 2.x is the naming of the columns. This version of the gem
155164
allows specifying the name of the column from the gem configuration:
156165

157166
```ruby
@@ -163,6 +172,7 @@ end
163172
```
164173

165174
### Upgrading from delynn's 2.x without `compatibility_mode`
175+
166176
Within migrations, it was possible to declare `t.userstamps` within a table definition. It used
167177
to accept one argument, which declares whether the deleter column should be created. This has
168178
been changed to respect the gem configuration's `deleter_attribute`. If that is `nil`, then no
@@ -182,16 +192,18 @@ Configure the gem to use those names (as above) and remove all `stampable` decla
182192
There is no need to include the `Userstamp` module in `ApplicationController`.
183193

184194
## Tests
195+
185196
Run
186197

187198
$ bundle exec rspec
188199

189200
## Authors
190-
- [DeLynn Berry](http://delynnberry.com/): The original idea for this plugin came from the Rails
191-
Wiki article entitled
192-
[Extending ActiveRecord](http://wiki.rubyonrails.com/rails/pages/ExtendingActiveRecordExample)
193-
- [Michael Grosser](http://pragmatig.com)
194-
- [John Dell](http://blog.spovich.com/)
195-
- [Chris Hilton](https://github.com/chrismhilton)
196-
- [Thomas von Deyen](https://github.com/tvdeyen)
197-
- [Joel Low](http://joelsplace.sg)
201+
202+
- [DeLynn Berry](http://delynnberry.com/): The original idea for this plugin came from the Rails
203+
Wiki article entitled
204+
[Extending ActiveRecord](http://wiki.rubyonrails.com/rails/pages/ExtendingActiveRecordExample)
205+
- [Michael Grosser](http://pragmatig.com)
206+
- [John Dell](http://blog.spovich.com/)
207+
- [Chris Hilton](https://github.com/chrismhilton)
208+
- [Thomas von Deyen](https://github.com/tvdeyen)
209+
- [Joel Low](http://joelsplace.sg)

0 commit comments

Comments
 (0)