You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, we are using paper_trail in a non Rails Project, just together with ActiveRecord. PaperTrail is in this situation not dynamically loaded, so we have to load it manually with require 'paper_trail' before defining our models. So far so good.
On loading, the config.rb is doing a database lookup to check whether the table version_associations is available or not (https://github.com/airblade/paper_trail/blob/4.1-stable/lib/paper_trail/config.rb#L32). As in our case the database connection is done later, we encounter the error No connection pool for PaperTrail::VersionAssociation (ActiveRecord::ConnectionNotEstablished)
We could fix this with the simple Monkey Patch below. As we are not using the track-association-feature, we just overwrite the PaperTrail::Config.track_associations? method before loading paper_trail. In my opinion, it would be better to explicit enable/disable the track_association feature instead of magically enable it when the table exists. This would fix the loading problem in a non rails environment.
require 'paper_trail/config'
module PaperTrail
class Config
def track_associations?
false
end
end
end
require 'paper_trail'
The text was updated successfully, but these errors were encountered:
Hello, we are using paper_trail in a non Rails Project, just together with ActiveRecord. PaperTrail is in this situation not dynamically loaded, so we have to load it manually with
require 'paper_trail'
before defining our models. So far so good.On loading, the config.rb is doing a database lookup to check whether the table
version_associations
is available or not (https://github.com/airblade/paper_trail/blob/4.1-stable/lib/paper_trail/config.rb#L32). As in our case the database connection is done later, we encounter the errorNo connection pool for PaperTrail::VersionAssociation (ActiveRecord::ConnectionNotEstablished)
We could fix this with the simple Monkey Patch below. As we are not using the track-association-feature, we just overwrite the
PaperTrail::Config.track_associations?
method before loading paper_trail. In my opinion, it would be better to explicit enable/disable the track_association feature instead of magically enable it when the table exists. This would fix the loading problem in a non rails environment.The text was updated successfully, but these errors were encountered: