Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with Rails 4.2.x when not using STI for version models #492

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -578,18 +578,7 @@ Alternatively you could store certain metadata for one type of version, and othe

If you only use custom version classes and don't use PaperTrail's built-in one, on Rails `>= 3.2` you must:

- either declare the `PaperTrail::Version` class to be abstract like this (in an initializer):

```ruby
# config/initializers/paper_trail.rb

# the following line is required for PaperTrail >= 4.0.0 with Rails
PaperTrail::Rails::Engine.eager_load!

PaperTrail::Version.module_eval do
self.abstract_class = true
end
```
- either use `PaperTrail::AbstractVersion`

- or create a `versions` table in the database so Rails can instantiate the `PaperTrail::Version` superclass.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'paper_trail/version_concern'

module PaperTrail
# When using PaperTrail with multiple tables without STI
# PaperTrail::Versions needs to be abstract or you have to create
# an unused versions table since Rails now reloads gemfiles as well
# as application code and the preferred method was to use an initializer
# which isn't reloaded resulting in PaperTrail::Version not being abstract.
#
# For details see #488 and #483
#
# So if you want an abstract base class and not use sti use AbstractVersion as
# your parent class.
class AbstractVersion < ::ActiveRecord::Base
include PaperTrail::VersionConcern
self.abstract_class = true
end
end