ruby-on-rails – 开发模式下的异常页面渲染时间超过15-30秒,为什么会这样?

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 开发模式下的异常页面渲染时间超过15-30秒,为什么会这样?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用Rails 3 beta 4,出于某种原因,我有每个例外需要15-30秒才能显示.这是我的踪迹:
Started GET "/something/something/approvals/new" for 127.0.0.1 at Thu Jun 24 21:17:12 -0400 2010
  sql (1.8ms)  describe `approvals_users`
  sql (24.6ms)  describe `clients_users`
  sql (1.4ms)  describe `agencies_users`
  sql (1.2ms)  describe `clients_users`
  sql (1.2ms)  describe `approvals_users`
  sql (1.7ms)  describe `permissions_users`
  Processing by ApprovalsController#new as HTML
  Parameters: {"project_id"=>"tricked","client_id"=>"deez-nutz"}
  sql (1.4ms)  describe `agencies_users`
  Agency Load (0.4ms)  SELECT `agencies`.* FROM `agencies` WHERE (`agencies`.`subdomain` = 'subdomain') LIMIT 1
  Plan Load (0.3ms)  SELECT `plans`.* FROM `plans` WHERE (`plans`.`id` = 3) LIMIT 1
  User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 1) LIMIT 1
Completed   in 93ms

NoMethodError (undefined method `humanize' for nil:NilClass):
  app/models/approval.rb:38:in `state'
  app/models/approval.rb:38:in `state'
  app/controllers/approvals_controller.rb:10:in `new'
  app/controllers/approvals_controller.rb:10:in `new'

Rendered /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-6682cce0386811ffe3e6d31fc025ede0936d86c3/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.9ms)
  sql (2.5ms)  SHOW TABLES
  sql (0.9ms)  SHOW TABLES
  sql (0.9ms)  SHOW TABLES
  sql (0.9ms)  SHOW TABLES
  sql (0.9ms)  SHOW TABLES
  sql (0.9ms)  SHOW TABLES
  sql (0.9ms)  SHOW TABLES
  sql (0.9ms)  SHOW TABLES
Rendered /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-6682cce0386811ffe3e6d31fc025ede0936d86c3/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (21433.7ms)
Rendered /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-6682cce0386811ffe3e6d31fc025ede0936d86c3/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (21630.2ms)

如果它有帮助,这是我的Gemfile:

source 'http://gemcutter.org'

# Core
# gem 'rails','3.0.0.beta4'
gem 'rails',:git => 'http://github.com/rails/rails.git'
gem 'sinatra'
gem 'MysqL'
gem 'bundler'
gem 'memcache-client'
gem 'system_timer'
gem 'mime-types',:require => 'mime/types'
gem 'json'
gem 'haml','~> 3.0.12'
gem 'state_machine'
gem 'bcrypt-ruby',:require => 'bcrypt'
gem 'juicer'
gem 'hoptoad_notifier'
gem 'braintree'
gem 'panda'

# Templating
gem 'liquid','2.0.0'

# Users
gem 'warden'
gem 'ruby-openid',:require => 'openid'
gem 'canable'
gem 'devise'

# Paperclip
gem 'aws-s3',:require => 'aws/s3'
gem 'paperclip',:git => 'git://github.com/dewski/paperclip.git',:branch => 'rails3'
gem 'delayed_job',:git => 'git://github.com/dewski/delayed_job.git'

group :test do
  gem 'webrat'
  gem 'hpricot'
  gem 'mocha',:require => false
end

如果我创建一个新的Rails应用程序,错误页面会立即显示.在Rails源代码中,具有SHOW TABLES的方法是schema_statements.rb中的structure_dump.我在我的bundler目录中搜索了对这种方法的任何调用,它没有显示任何内容.是什么原因以及如何引起SHOW TABLES被一遍又一遍地调用,并且可能使得每个方法都让调试变得痛苦?

解决方法

我们在我们公司遇到了这个问题,在我们等待正式的Rails点发布时,已经整理了一个黑客.正如在其他答案中链接的Lighthouse票据中提到的关键问题似乎是对于某些应用程序,request.env包含一些#inspect输出为巨大的对象(例如,兆字节的文本),并且此输出全部被放置进入错误页面.

所以这里是:

# development.rb

config.after_initialize do    
  module SmallInspect
    def inspect
      "<#{self.class.name} - tooooo long>"
    end
  end
  [ActionDispatch::RemoteIp::RemoteIpGetter,OmniAuth::Strategies::Facebook,ActionController::Base,Warden::Proxy].each do |klazz|
    klazz.send(:include,SmallInspect)
  end
end

列出的课程是我们的主要罪魁祸首;你的应用程序会有所不同.

原文链接:https://www.f2er.com/ruby/267412.html

猜你在找的Ruby相关文章