未定义的方法和路由错误需要花费大量时间

时间:2012-02-09 10:00:15

标签: ruby ruby-on-rails-3 rails-routing

由于我将应用程序从Rails 2.3.5更新为当前运行3.2.1的Rails 3,未定义的方法和路由错误需要花费大量时间。每当我有一些方法丢失时,我的Macbook Pro就会冻结,在3/4分钟后我会收到相应的错误。

当我有一个未定义的方法时,你有一个完整的堆栈跟踪,奇怪的是,diagnostics.erb加载149863毫秒,这是不正常的我猜:

https://gist.github.com/1778939

堆栈跟踪中应用程序级别的唯一调用是我的application_controller.rb中的method_missing,这是我正在使用的方法:

def method_missing(method_id, *arguments)
  # Define a authorize_type dynamic authorization thingiemagiggy
  if match = /authorize_([_a-zA-Z]+)/.match(method_id.to_s)
    return authorize(match[1])
  else
    super
  end
end

我还会添加一个路由错误的堆栈跟踪,看起来这些视图需要花费很长时间才能加载,但这个视图中只有一个链接:

https://gist.github.com/1779027

有人可以解释一下为什么这种错误的发布需要花费很多时间以及如何解决它?

1 个答案:

答案 0 :(得分:1)

终于找到了如何在github上的rails问题的帮助下修复它:https://github.com/rails/rails/issues/1525

我创建了一个初始化程序anti_freeze.rb,其中包含:

module ActionDispatch
  module Routing
    class RouteSet
      alias inspect to_s
    end
  end
end
相关问题