在 Rails 3.1 中,想在 rails console
里测试一下路由规则,于是输入
r = Rails.application.routes
r.recognize_path "/"
结果报 Rack 的错误,看了一下 rack 的代码,晕, 遇到过的兄弟帮忙看看啥原因?
irb(main):002:0> r = Rails.application.routes
irb(main):002:0> r.recognize_path "/"
RuntimeError: route set not finalized
from C:/software/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:81:in `recognize'
from C:/software/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/routing/route_set.rb:546:in `recognize_path'
from (irb):2
from C:/software/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/commands/console.rb:45:in `start'
from C:/software/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/commands/console.rb:8:in `start'
from C:/software/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
irb(main):003:0>