0

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 byebugis 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:

Byebug

Active_model_serializer

Figaro

halfer
  • 19,824
  • 17
  • 99
  • 186
David
  • 7,028
  • 10
  • 48
  • 95
  • It's probably to provide some base functionality as to keep the system DRY - and further, software development is somewhat incestuous; once one gem creator does something, others follow :) – Richard Peck Jul 18 '14 at 10:04
  • I know why it is done. The question is a matter of why does it give me an error, but not them? – David Jul 18 '14 at 17:57
  • Ohhh - I didn't see the error. What's the message you've received? – Richard Peck Jul 18 '14 at 18:46
  • 1
    Actually, for some reason, it works now. The only issue I have now is the following: http://stackoverflow.com/questions/24831530/how-to-keep-my-gem-self-contained-without-having-to-edit-any-core-source-rails – David Jul 18 '14 at 18:50
  • Let me have a looook! – Richard Peck Jul 18 '14 at 19:06

0 Answers0