I am looking at a nasty issue with PaperTrail. We are redefining a class in app/models/paper_trail/version.rb that looks like
puts "I am loading"
module PaperTrail
class Version < ActiveRecord::Base
include PaperTrail::VersionConcern
with the specs and with rails zeitwerk:check we get the message
Zeitwerk@rails.main: file /Users/kireto/…/app/models/paper_trail/version.rb is ignored because PaperTrail::Version is already defined
The text “I am loading” is never printed.
Why is app/models/paper_trail/version.rb not loaded? It is in app/models, it is in the autoloaded and eager_load paths. Does zeitwerk look only at the first definition and ignores everything after that. Because there is a PaperTrail::Version in another gem that gets loaded first then app/models/paper_trail/version.rb is never read. Right? Then what will be the correct way to redefine a constant to load from our file?
Thanks.