使用纸质记录进行活动记录版本控制的单独数据库 gem

Separate database for active record versioning using paper trail gem

我正在尝试使用 papertrail 在单独的数据库中记录模型的更改事件。

我正在使用 Rails 4.1.2

Ruby2.1

Papertrail 4.0.0

下面是我在关注中添加的代码

module Foo
 class Base < ActiveRecord::Base
 end

 class Version < Base
  include PaperTrail::VersionConcern
 end

 class Topic < Base
  has_paper_trail class_name: 'Foo::Version'
 end
end
Foo::Base.establish_connection(:trail_development)

我已将此 Foo 包含在 topic.rb

class Topic < ActiveRecord::Base
 include Foo
end

怎么了?

引用https://github.com/airblade/paper_trail/pull/289

在查看 paper_trail gem 中的一些 tests 之后,我发现了一个 example spec 来测试您要达到的目标:https://github.com/airblade/paper_trail/blob/v3.0.0/spec/support/alt_db_init.rb