Correct use of concern's constants
I just came across the same bug, when trying to implement concerns.
The guide I was following also but the Constant in the included block and seemed to have no error. But my log threw me exactly the same error you have.
After some trial and error, I just removed the Constant from the block and put it outside, like:
module UserInstance
extend ActiveSupport::Concern
included do
end
ACTIVE = 'active'
end
This way I could still access the Constant, but didn't get anymore errors. I'm not 100% sure that this is the right way, but it worked and I couldn't find any errors, so I will go with it.
I would like to now if this works for you too!
Using base
solved the problem for me.
module UserInstance
extend ActiveSupport::Concern
# https://api.rubyonrails.org/v6.0.0/classes/ActiveSupport/Concern.html#method-i-included
included do |base|
base.const_set :ACTIVE, "active"
# direct const creation in this included block will attach the const to the concern module, not the including class
# so if you have multiple classes including the same concern, it will try to difine the same const to the same module
# ACTIVE = "active"
end
end