【问题标题】:Mongrel Rails error: RoutingError (No route matches "/://0" with {:method=>:get}):Mongrel Rails 错误:RoutingError(没有与 {:method=>:get} 匹配的路由“/://0”):
【发布时间】:2010-10-16 23:32:14
【问题描述】:

我一直在我的 Rails 生产日志中看到这个错误,有什么问题吗? 我在 apache 上使用 mongrel 集群运行 rails。 RoutingError (没有路由匹配 "/://0" 与 {:method=>:get}):

不确定是什么尝试的 url 导致了错误。

编辑:这是我的 routes.rb 文件

ActionController::Routing::Routes.draw 做 |map|

map.signout '/account/signout', :controller => 'sessions', :action => 'destroy'
map.signin '/account/signin', :controller => 'sessions', :action => 'new'
map.signup '/account/signup', :controller => 'users', :action => 'new'

map.change_password '/account/change_password', :controller => 'users', :action => 'change_password'
map.forgot_password '/account/forgot_password', :controller => 'users', :action => 'forgot_password'
map.reset_password '/account/reset_password/:id', :controller => 'users', :action => 'reset_password'   

map.preferences '/preferences', :controller => 'preferences', :action => 'index'
map.dashboard '/dashboard', :controller => 'dashboard', :action => 'index'
map.account '/account', :controller => 'account', :action => 'index'
map.affiliate '/affiliates', :controller => 'affiliates', :action => 'index'

map.essentials '/preferences/essentials', :controller => 'preferences/essentials', :action => 'index'
map.contacts '/preferences/contacts', :controller => 'preferences/contacts', :action => 'index'
map.travel '/preferences/travel', :controller => 'preferences/travel', :action => 'index'
map.online '/preferences/online', :controller => 'preferences/online', :action => 'index'
map.reminders '/preferences/reminders', :controller => 'preferences/reminders', :action => 'index'
map.miscellaneous '/preferences/miscellaneous', :controller => 'preferences/miscellaneous', :action => 'index'

map.home '/home', :controller => 'main', :action => 'home'
map.about '/about', :controller => 'main', :action => 'about'
map.gift '/gift', :controller => 'gift', :action => 'index'
map.plans '/plans', :controller => 'main', :action => 'plans'
map.faqs '/faqs', :controller => 'main', :action => 'faqs'
map.contact '/contact', :controller => 'main', :action => 'contact'

map.tos '/terms_of_service', :controller => 'main', :action => 'terms_of_service'
map.privacy '/privacy', :controller => 'main', :action => 'privacy'

map.root :controller => 'main'

map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'

结束

rails 错误日志中的完整错误消息:

ActionController::RoutingError (No route matches "/account/://0" with {:method=>:get}):
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/routing/recognition_optimisation.rb:66:in `recognize_path'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/routing/route_set.rb:386:in `recognize'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:182:in `handle_request'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:110:in `dispatch_unlocked'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:123:in `dispatch'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:in `synchronize'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:in `dispatch'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:132:in `dispatch_cgi'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:39:in `dispatch'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:in `process'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `synchronize'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `process'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:159:in `process_client'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `each'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `process_client'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `initialize'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `new'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `initialize'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `new'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:282:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `each'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run'
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/usr/local/bin/mongrel_rails:19:in `load'
/usr/local/bin/mongrel_rails:19

apache vhost 文件摘录:

  RewriteCond %{SERVER_PORT} !^443$
  RewriteRule ^/(.*)$ https://%{SERVER_NAME}/$1 [R,L]

  # Redirect all non-static requests to Mongrel
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule ^/(.*)$ balancer://mongrel1%{REQUEST_URI} [P,QSA,L]

  <Proxy balancer://mongrel1>
    BalancerMember http://127.0.0.1:3000
    BalancerMember http://127.0.0.1:3001
  </Proxy>

  ProxyPass / balancer://mongrel1/
  ProxyPassReverse / balancer://mongrel1/
  ProxyPreserveHost on

谢谢!

【问题讨论】:

  • 需要更多信息,例如您是如何收到该错误的。那将是一个好的开始。
  • 人们似乎忽略了对 /account/://0 的实际请求正在发生的事实。检查 apache 日志文件,看看是否有这些请求的引用者。

标签: ruby-on-rails routing


【解决方案1】:

呃 - 问题似乎是有人请求"/account/://0" 的 URL?为什么会产生路由错误?我不希望这会击中您定义的任何路线。

【讨论】:

    【解决方案2】:

    这可能只是一次黑客攻击吗?

    【讨论】:

      【解决方案3】:

      您的 config/routes.rb 文件中似乎存在问题。

      如果您可以将 routes.rb 文件的内容和您尝试加载的 URL 添加到您的消息中,我们可以提供进一步的帮助。

      【讨论】:

        【解决方案4】:

        map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format'

        按照下面给出的顺序交换这些语句。

        map.connect ':controller/:action/:id.:format' map.connect ':controller/:action/:id'

        在 routes.rb 中没有提供 restful 路由,因此问题可能不在于方法定义或调用任何成员方法。

        格式只是覆盖了 url 源。

        【讨论】:

          猜你喜欢
          • 2014-12-12
          • 2013-04-21
          • 2018-11-21
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-03-21
          相关资源
          最近更新 更多