我在Heroku上運行Cedar堆棧,rails 3.1.3。Heroku未初始化的常量Rails:初始化程序(NameError)(noWWW Rack Middleware)
使用: http://trevorturk.com/2009/11/05/no-www-rack-middleware/
當我推到Heroku的,我得到:
app[web.1]: => Rails 3.1.3 application starting in production on http://0.0.0.0:15548
app[web.1]: => Call with -d to detach
app[web.1]: => Ctrl-C to shutdown server
app[web.1]: Exiting
app[web.1]: /app/config/environment.rb:7:in `<top (required)>': uninitialized constant Rails::Initializer (NameError)
任何人有什麼回事任何想法?
這裏是我的environment.rb
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
AppName::Application.initialize!
Rails::Initializer.run do |config|
config.middleware.use "NoWWW" if RAILS_ENV == 'production'
end
的lib/no_www.rb(我的應用程序AppName的正確=名稱即那不是問題。):
class NoWWW
STARTS_WITH_WWW = /^www\./i
def initialize(app)
@app = app
end
def call(env)
if env['HTTP_HOST'] =~ STARTS_WITH_WWW
[301, { 'Location' => Rack::Request.new(env).url.sub(/www\./i, '') }, ['Redirecting...']]
else
@app.call(env)
end
end
end
任何想法如何實現我想要的機架重寫? github上的README並不能很好地解釋... – David 2012-01-12 03:18:04