I have the following classes in my applications lib directory:
proxy.rb
class Proxy
end
ga_proxy.rb
class GaProxy < Proxy
include GaProxy::Metrics
end
metrics.rb
class GaProxy
module Metrics
end
end
Load order clearly matters here:
metrics.rb need to be loaded before ga_proxy.rb
proxy.rb needs to be loaded before ga_proxy.rb
But if metrics.rb is loaded before ga_proxy, then I get 'superclass mismatch for class GaProxy' because GaProxy has already been defined without a parent class.
How can I get around this issue?
Thanks
In your application.rb file, specify each file you want to load in order:
config.autoload_paths += %W( #{config.root}/lib/proxy.rb, #{config.root}/lib/metrics.rb, #{config.root}/lib/ga_proxy.rb )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With