加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 奇怪的Active Admin(Rails)错误

发布时间:2020-12-17 03:54:15 所属栏目:百科 来源:网络整理
导读:这是迄今为止我遇到的最荒谬的错误之一.我登录到活动管理员,并在我的屏幕上显示任何活动的管理页面: (ⅰ-MX: /体GT) 我检查了服务器日志,我似乎成功登录,服务器计算所有列的查询,但最终输出是上面的!我使用ruby 1.9.3,rails 3.1.3,活动管理版0.4.4. 以下
这是迄今为止我遇到的最荒谬的错误之一.我登录到活动管理员,并在我的屏幕上显示任何活动的管理页面:

(ⅰ-MX:< /体&GT)

我检查了服务器日志,我似乎成功登录,服务器计算所有列的查询,但最终输出是上面的!我使用ruby 1.9.3,rails 3.1.3,活动管理版0.4.4.

以下是其中一个页面加载的示例日志输出:

Started GET "/admin/points_logs" for 127.0.0.1 at 2012-08-01 09:01:10 -0400
  Processing by Admin::PointsLogsController#index as HTML
Geokit is using the domain: localhost
  AdminUser Load (0.4ms)  SELECT `admin_users`.* FROM `admin_users` WHERE `admin_users`.`id` = 1 LIMIT 1
   (30.9ms)  SELECT 1 FROM `points_logs` LIMIT 1 OFFSET 0
   (92.0ms)  SELECT COUNT(*) FROM `points_logs` 
  CACHE (0.0ms)  SELECT COUNT(*) FROM `points_logs` 
  CACHE (0.0ms)  SELECT COUNT(*) FROM `points_logs` 
  CACHE (0.0ms)  SELECT COUNT(*) FROM `points_logs` 
  PointsLog Load (0.7ms)  SELECT `points_logs`.* FROM `points_logs` ORDER BY `points_logs`.`id` desc LIMIT 30 OFFSET 0
  User Load (0.6ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 56 LIMIT 1
  User Load (0.7ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 2654 LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 56 LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 56 LIMIT 1
  User Load (0.8ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1122 LIMIT 1
  User Load (0.5ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 718 LIMIT 1
  User Load (0.5ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 3689 LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 3689 LIMIT 1
  User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 821 LIMIT 1
  User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 958 LIMIT 1
  User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 4708 LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 958 LIMIT 1
  User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 5137 LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 5137 LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 5137 LIMIT 1
  User Load (0.7ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 3598 LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 3598 LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 5137 LIMIT 1
  User Load (0.6ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 413 LIMIT 1
  User Load (0.5ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 4324 LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 4324 LIMIT 1
  User Load (0.6ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1812 LIMIT 1
  User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 3726 LIMIT 1
  User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1101 LIMIT 1
  User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 2440 LIMIT 1
  User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 3369 LIMIT 1
  User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 3702 LIMIT 1
  User Load (0.5ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 5026 LIMIT 1
  User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 684 LIMIT 1
  User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1444 LIMIT 1
  Transaction Load (0.3ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40464 LIMIT 1
  Transaction Load (0.4ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 29394 LIMIT 1
  Transaction Load (0.3ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 32958 LIMIT 1
  Transaction Load (0.3ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 37409 LIMIT 1
  Transaction Load (0.4ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40463 LIMIT 1
  Transaction Load (0.4ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40462 LIMIT 1
  Transaction Load (0.3ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40461 LIMIT 1
  CACHE (0.0ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` =  LIMIT 1
  Transaction Load (0.3ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40460 LIMIT 1
  Transaction Load (0.3ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40459 LIMIT 1
  Transaction Load (0.3ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40458 LIMIT 1
  Transaction Load (0.3ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40457 LIMIT 1
  Transaction Load (0.3ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40454 LIMIT 1
  CACHE (0.0ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` =  LIMIT 1
  Transaction Load (0.3ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40452 LIMIT 1
  Transaction Load (0.3ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40451 LIMIT 1
  CACHE (0.0ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` =  LIMIT 1
  Transaction Load (0.3ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40450 LIMIT 1
  Transaction Load (0.3ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40449 LIMIT 1
  Transaction Load (0.3ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40448 LIMIT 1
  Transaction Load (0.3ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40447 LIMIT 1
  Transaction Load (0.3ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40446 LIMIT 1
  Transaction Load (0.3ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40445 LIMIT 1
  Transaction Load (0.3ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40443 LIMIT 1
  Transaction Load (0.3ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40442 LIMIT 1
  Transaction Load (0.6ms)  SELECT `transactions`.* FROM `transactions` WHERE `transactions`.`id` = 40441 LIMIT 1
  User Load (278.6ms)  SELECT `users`.* FROM `users` 
Rendered /Users/bpn/.rvm/gems/ruby-1.9.3-p194@_1.9.3/gems/activeadmin-0.4.4/app/views/active_admin/resource/index.html.arb (2594.3ms)
Completed 200 OK in 3168ms (Views: 2084.9ms | ActiveRecord: 755.6ms)
</p>

解决方法

通过查看 mini-profiler docs并查看 config class中的可用配置选项,我找到了一种更清晰的方法来处理这个问题

在config / initializers / mini_profiler.rb中

Rack::MiniProfiler.config.skip_paths << '/admin' #or whatever you namespace active_admin under

注意,还有一些其他有用的配置设置:

Rack::MiniProfiler.config.use_existing_jquery = true
Rack::MiniProfiler.config.pre_authorize_cb = lambda {|env| Rails.env.development?}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读