Rails プロジェクトで作成したばかげた小さな Rack gem を使用しようとしていますが、uninitialized constant
呼び出すたびにエラーが発生します。私は以前にRack gemを書いたことがあり、それらは私のRailsプロジェクトで問題なく動作するので、これは私を狂わせます。
私のGemfileで:
gem 'hide_heroku', :git => 'https://github.com/ykessler/hide-heroku'
私のapplication.rbで:
module Tester
class Application < Rails::Application
config.middleware.use Rack::HideHeroku
しかし、ローカルサーバーを起動すると、次のようになります。
初期化されていない定数 Rack::HideHeroku (NameError)
宝石:
module Rack
class HideHeroku
def initialize(app)
@app=app
end
def call(env)
@status, @headers, @response = @app.call(env)
@request = Rack::Request.new(env)
[@status, _apply_headers, @response]
end
private
def _apply_headers
if /\.herokuapp\.com\/?.*/ =~ @request.url
@headers['X-Robots-Tag'] = 'noindex, nofollow'
end
@headers
end
end
end
こちらをご覧ください: https://github.com/ykessler/hide-heroku