Skip to content

Commit

Permalink
Merge pull request #1330 from Hugo-Hache/fix-custom-version-class-aut…
Browse files Browse the repository at this point in the history
…oloading-issue

Use an app specific name for abstract version class to avoid autoloading conflict
  • Loading branch information
tlynam authored Sep 2, 2021
2 parents 6157c81 + 559211a commit 9e82585
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1208,17 +1208,20 @@ class PostVersion < PaperTrail::Version
end
```

If you only use custom version classes and don't have a `versions` table, you
must let ActiveRecord know that the `PaperTrail::Version` class is an
`abstract_class`.
If you only use custom version classes and don't have a `versions` table, you must
let ActiveRecord know that your base version class (eg. `ApplicationVersion` below)
class is an `abstract_class`.

```ruby
# app/models/paper_trail/version.rb
module PaperTrail
class Version < ActiveRecord::Base
include PaperTrail::VersionConcern
self.abstract_class = true
end
# app/models/application_version.rb
class ApplicationVersion < ActiveRecord::Base
include PaperTrail::VersionConcern
self.abstract_class = true
end

class PostVersion < ApplicationVersion
self.table_name = :post_versions
self.sequence_name = :post_versions_id_seq
end
```

Expand Down

0 comments on commit 9e82585

Please sign in to comment.