2

I want to use this rack middleware in my rails app, followed every solutions on another SO post but still no luck, keep on getting uninitialized constant error.

So, what's the precise location to put the rack middleware file and include the config.middleware.use in Rails 3.2.3? Thanks.

Community
  • 1
  • 1
shinnc
  • 899
  • 7
  • 16

1 Answers1

1

I suspect you're getting this error because you're not requiring the file anywhere. There's two ways you can get around this.

The first is to actually require the file that defines your constant, in a place like config/application.rb and before the constant is referenced.

The second is to add the lib directory to the autoload_paths for your application (which I explain here) and so that when this constant is referenced, the matching file wil be loaded.

Your choice.

Ryan Bigg
  • 106,965
  • 23
  • 235
  • 261
  • I've tried adding `require "lib/ServerProxy"`. When I run `rake middleware`, somehow it shows me `cannot load such file -- lib/ServerProxy`. While I tried with the second method, the rack file did not shown up on the list. Am I missing any necessary steps? – shinnc Apr 15 '12 at 16:57
  • 1
    so I think you lib file name is server_proxy.rb. try "require 'server_proxy'" – lfx_cool Apr 17 '13 at 03:48