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
Due to limited volunteers, issues that do not follow these instructions will be
closed without comment.
Check the following boxes:
This is not a usage question, this is a bug report
This bug can be reproduced with the script I provide below
This bug can be reproduced in the latest release of the paper_trail gem
Due to limited volunteers, we cannot answer usage questions. Please ask such
questions on StackOverflow.
Bug reports must use the following template:
# frozen_string_literal: true# Use this template to report PaperTrail bugs.# Please include only the minimum code necessary to reproduce your issue.require"bundler/inline"# STEP ONE: What versions are you using?gemfile(true)doruby"3.3.0"source"https://rubygems.org"gem"activerecord"gem"minitest"gem"paper_trail","12.1.0",require: falsegem"sqlite3","~> 1.4"endrequire"active_record"require"minitest/autorun"require"logger"# Please use sqlite for your bug reports, if possible.ActiveRecord::Base.establish_connection(adapter: "sqlite3",database: ":memory:")ActiveRecord::Base.logger=nilActiveRecord::Schema.definedo# STEP TWO: Define your tables here.create_table:users,force: truedo |t|
t.string:typet.text:first_name,null: falset.timestampsnull: falseendcreate_table:versionsdo |t|
t.string:item_type,null: falset.integer:item_id,null: falset.string:event,null: falset.string:whodunnitt.text:object,limit: 1_073_741_823t.text:object_changes,limit: 1_073_741_823t.datetime:created_atendadd_index:versions,%i[item_typeitem_id]endActiveRecord::Base.logger=Logger.new(STDOUT)require"paper_trail"# STEP FOUR: Define your AR models here.classUser < ActiveRecord::Basehas_paper_trailendclassAdmin < Userhas_paper_trailon: [:create]end# STEP FIVE: Please write a test that demonstrates your issue.classBugTest < ActiveSupport::TestCasedeftest_1assert_difference(->{PaperTrail::Version.count}, +1){User.create(first_name: "Jane")}enddeftest_2assert_difference(->{PaperTrail::Version.count}, +1){Admin.create(first_name: "Jane")}endend# STEP SIX: Run this script using `ruby my_bug_report.rb`
When the root class is created class MyModel < ApplicationRecord, it calls has_paper_trail and when class MyOtherModel < MyModel is created, it calls it again.
I would expect the gem to raise an error if that's not allowed or simple ignore the call if nothing has changed, or even better, respect the options for the STI models in the case it is different from the root model.
The text was updated successfully, but these errors were encountered:
Thank you for your contribution!
Due to limited volunteers, issues that do not follow these instructions will be
closed without comment.
Check the following boxes:
paper_trail
gemDue to limited volunteers, we cannot answer usage questions. Please ask such
questions on StackOverflow.
Bug reports must use the following template:
Our real scenario is actually like this:
When the root class is created
class MyModel < ApplicationRecord
, it callshas_paper_trail
and whenclass MyOtherModel < MyModel
is created, it calls it again.Current workaround:
I would expect the gem to raise an error if that's not allowed or simple ignore the call if nothing has changed, or even better, respect the options for the STI models in the case it is different from the root model.
The text was updated successfully, but these errors were encountered: