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

发布于 2025-01-04 02:38:12 字数 835 浏览 2 评论 0原文

由于我将应用程序从 Rails 2.3.5 更新到 Rails 3,目前运行的是 3.2.1,未定义的方法和路由错误需要花费大量时间。每当我缺少某种方法时,我的 Macbook Pro 就会死机,3/4 分钟后我就会收到相应的错误。

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

https://gist.github.com/1778939

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

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

有人可以解释一下为什么启动这种错误需要这么长时间时间和我该如何修复它?

Since I updated my application from Rails 2.3.5 to Rails 3, currently running 3.2.1, undefined method and routing errors take a lot of time. Every time I have some method missing my Macbook Pro is freezing and after 3/4 minutes I get the corresponding error.

Here you have a full stack trace when I have an undefined method, the thing that is strange is that the diagnostics.erb takes 149863 ms to load, this is not normal I guess :

https://gist.github.com/1778939

The only call on application level that is in the stack trace is the method_missing in my application_controller.rb, here is the method I'm using :

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

I also will add a stack trace of a routing error, there it seems that the views take ages to load, but there is just a link to in this views:

https://gist.github.com/1779027

Somebody can explain me why the launching of this kind of errors takes so much time and how I can fix it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦幻之岛 2025-01-11 02:38:12

最后在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

Finally found out how to fix it with the help of the rails issue on github : https://github.com/rails/rails/issues/1525

I made an initializer anti_freeze.rb that contains :

module ActionDispatch
  module Routing
    class RouteSet
      alias inspect to_s
    end
  end
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文