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

The "paper_trail" initializer is not guaranteed to execute before the "load_config_initializers" initializer #1437

Closed
glasses618 opened this issue Aug 28, 2023 · 1 comment
Labels

Comments

@glasses618
Copy link

glasses618 commented Aug 28, 2023

Summary

The name of load_config_initializers which is used for registering "paper_trail" initializer's before-initializer should be :load_config_initializers instead of 'load_config_initializers'. Please refer to https://github.com/rails/rails/blob/3668b4b5978822f1e6311c7fd7a32f58daee136a/railties/lib/rails/engine.rb#L618.

initializer "paper_trail", before: "load_config_initializers" do

Reproduce script

  • All tsort_each_child of initializers of load_config_initializers should contain 'paper_trail' initializer.

P.S. The original template cannot be utilized to reproduce this issue, so I've prepared an alternative script.

Script

  1. Prepare a Rails app
  2. Add gem 'paper_trail', '15.0.0' into Gemfile and run bundle install
  3. In rails console, run the following script:
initializers_of_load_config_initializers = Rails.application.initializers.select{ |s| s.name == :load_config_initializers }

initializers = Rails.application.initializers
initializers_of_load_config_initializers.map do |initializer| 
  initializers.tsort_each_child(initializer).any?{|s| s.name == 'paper_trail' }
end

expected result

=> [true, true, true, true, true, true, true, true, true]

Actual result

=> [false, false, false, false, false, false, false, false, false]

Fix

  • Replace step 2's gem 'paper_trail', '15.0.0' with gem 'paper_trail', github: 'glasses618/paper_trail', branch: 'master' can fix the problem.

Environment

Rails version

7.0.7.2

Ruby version

3.2.2

paper_trail version

15.0.0

Related rails source codes

@glasses618 glasses618 changed the title The configured before options for the "paper_trail" initializer are not being set correctly. The configured before options for the "paper_trail" initializer are not being set correctly Aug 28, 2023
@glasses618 glasses618 changed the title The configured before options for the "paper_trail" initializer are not being set correctly The "paper_trail" initializer is not guaranteed to execute before the "load_config_initializers" initializer Aug 28, 2023
Copy link

This issue has been automatically marked as stale due to inactivity.
The resources of our volunteers are limited.
Bug reports must provide a script that reproduces the bug, using our template. Feature suggestions must include a promise to build the feature yourself.
Thank you for all your contributions.

@github-actions github-actions bot added the Stale label Nov 27, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant