I am trying to re-open a class in Rails that comes from an engine. I did the following:
module Xaaron
ApiKey.class_eval do
include Promiscuous::Publisher
publish :xaaron_users_id, :api_key, :as => :ApiKey
end
end
which sits in:
models/
Xaaron/
api_key.rb
This is all in my app, which should then let me run:
bundle exec promiscuous publish "Xaaron::ApiKey.all"
But, when I do, I get the error:
RuntimeError: Circular dependency detected while autoloading constant Xaaron::ApiKey
TL;DR: Try renaming
api_key.rbto something else.Here is what I think is happening: Rails autoloader loads
Xaaron/api_key.rband encounters an unknown constantXaaron::ApiKey. It then tries to load it from file called (based on constant name)...Xaaron/api_key.rb. Boom, circular dependency.