I am getting this error:
correlation_id/lib/correlation_id/controller_extension.rb:1:in <top (required)>': uninitialized constant CorrelationId (NameError)
The following is based on what is generated by the command rails plugin new correlation_id
In the lib
folder:
correlation_id.rb
require 'correlation_id/controller_extension'
module CorrelationId
end
correlation_id/controller_extension.rb
module CorrelationId
module ControllerExtension
def self.included(klass)
klass.class_eval do
after_filter :pass_correlation_id
end
end
def pass_correlation_id
correlation_id = request.headers['Correlation-ID'] || SecureRandom.uuid
headers['Correlation-ID'] = correlation_id
end
end
end
byebug
ApplicationController.send :include, CorrelationId::ControllerExtension
Now, let's for a moment forget the fact that for some reason I get an error because my gem doesn't know what byebug
is or can't figure our what ApplicationController
is. Why can't I require the second file in the first? I get the error as listed above!
All the cool kids manage to do this, but I can't! Check it out: