-
Notifications
You must be signed in to change notification settings - Fork 163
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
Nothing happens and nothing appear #223
Comments
At least in my case that was because I am using Puma with threads. I'm not sure why, but this piece of code uses thread-local-storage members to enable footnotes: rails-footnotes/lib/rails-footnotes.rb Lines 11 to 13 in f46e14c
Changing I am far from a Ruby expert, but this monkey-patch in module Footnotes
# the original implementation uses thread_mattr_accessor which doesn't work well with puma.
# puma creates multiple threads and each of them has a different value for the same variable.
# Footnotes.setup below only happens on the main thread and the value is NOT shared.
# this code below is a workaround to make it work with puma.
mattr_accessor :before_hooks, default: []
mattr_accessor :after_hooks, default: []
mattr_accessor :enabled, default: false
end
Footnotes.setup do |f|
f.enabled = Rails.env.development?
end |
There is no need for thread-local-storage here as nothing writes to any of these members beyond setup. TLS members have a separate value for each thread. Setup only happens on one thread. This means these members are not properly set on all threads. indirect#223
ruby 3.2.3
rails 7.1.3.2
rails-footnotes 7.1.0
rails_footnotes.rb
Footnotes.setup do |f|
f.enabled = Rails.env.development?
end if defined?(Footnotes) && Footnotes.respond_to?(:setup)
I start app in development mode, and nothing happens and nothing appears(
I tried add div in layout with id="footnotes_holder"
but it empty always(
There are no errors, but nothing happens.
The text was updated successfully, but these errors were encountered: