我似乎無法使用Rails 3.1(rc4)的簡單機架中間件。有什麼缺失?以下是我建我的應用程序:Rails 3.1rc4 + Rack:有什麼改變?
gem 'rack-contrib'
我這些行添加到config/application.rb
:
require 'rack/contrib'
...
config.middleware.use Rack::NotFound.new('public/404.html')
[注:
$ rails new skel192 -G -O -T
我在Gemfile
末加入這一行我我並沒有真正計劃使用RackNotFound
,我試圖使用我能想到的最簡單的中間件。]
那麼好措施:
$ bundle install
...
$ bundle update
...
FYI:
$ ruby -v
ruby 1.9.2p290 (2011-07-09) [i386-mingw32]
$ rails -v
Rails 3.1.0.rc4
但是當我運行:
$ rails server
=> Booting WEBrick
=> Rails 3.1.0.rc4 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0.rc4/lib/active_support/inflector/methods.rb:124:in `const_defined?': wrong constant name #<Rack (NameError)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0.rc4/lib/active_support/inflector/methods.rb:124:in `block in constantize'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0.rc4/lib/active_support/inflector/methods.rb:123:in `each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0.rc4/lib/active_support/inflector/methods.rb:123:in `constantize'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:527:in `block in initialize'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:549:in `yield'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:549:in `default'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:549:in `[]'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.1.0.rc4/lib/action_dispatch/middleware/stack.rb:24:in `klass'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.1.0.rc4/lib/action_dispatch/middleware/stack.rb:43:in `build'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.1.0.rc4/lib/action_dispatch/middleware/stack.rb:112:in `block in build'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.1.0.rc4/lib/action_dispatch/middleware/stack.rb:112:in `each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.1.0.rc4/lib/action_dispatch/middleware/stack.rb:112:in `inject'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.1.0.rc4/lib/action_dispatch/middleware/stack.rb:112:in `build'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0.rc4/lib/rails/engine.rb:429:in `app'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0.rc4/lib/rails/application/finisher.rb:37:in `block in <module:Finisher>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0.rc4/lib/rails/initializable.rb:25:in `instance_exec'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0.rc4/lib/rails/initializable.rb:25:in `run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0.rc4/lib/rails/initializable.rb:50:in `block in run_initializers'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0.rc4/lib/rails/initializable.rb:49:in `each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0.rc4/lib/rails/initializable.rb:49:in `run_initializers'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0.rc4/lib/rails/application.rb:96:in `initialize!'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0.rc4/lib/rails/railtie/configurable.rb:30:in `method_missing'
from C:/work/tech/external/lb/skel192/config/environment.rb:5:in `<top (required)>'
from C:/work/tech/external/lb/skel192/config.ru:4:in `require'
from C:/work/tech/external/lb/skel192/config.ru:4:in `block in <main>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.1/lib/rack/builder.rb:51:in `instance_eval'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.1/lib/rack/builder.rb:51:in `initialize'
from C:/work/tech/external/lb/skel192/config.ru:1:in `new'
from C:/work/tech/external/lb/skel192/config.ru:1:in `<main>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.1/lib/rack/builder.rb:40:in `eval'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.1/lib/rack/builder.rb:40:in `parse_file'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.1/lib/rack/server.rb:200:in `app'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0.rc4/lib/rails/commands/server.rb:46:in `app'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.1/lib/rack/server.rb:301:in `wrapped_app'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.3.1/lib/rack/server.rb:252:in `start'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0.rc4/lib/rails/commands/server.rb:70:in `start'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0.rc4/lib/rails/commands.rb:54:in `block in <top (required)>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0.rc4/lib/rails/commands.rb:49:in `tap'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.0.rc4/lib/rails/commands.rb:49:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
我缺少的東西?
你是對的(upvote!),但它仍然不適合我。我正在更新我的問題以納入您的建議。它似乎仍然是Rack的一些問題。 – jwfearn