Rails面板问题

时间:2015-07-08 04:15:11

标签: ruby-on-rails ruby-on-rails-3 better-errors-gem

我在Rails应用程序中使用chrome扩展Rails Panel。但它运作不正常。

的Gemfile

group :development do
  gem 'therubyracer', :platforms => :ruby
  gem 'better_errors'
  gem 'binding_of_caller'
  gem 'meta_request'
end

开发日志:

Errno::ENOENT - No such file or directory - /home/rahulv/sprint/S33/tmp/data/meta_request/d927421bce3c90bc465c9ceb894813ca.json:
  meta_request (0.3.4) lib/meta_request/storage.rb:16:in `read'
  meta_request (0.3.4) lib/meta_request/middlewares/meta_request_handler.rb:20:in `events_json'
  meta_request (0.3.4) lib/meta_request/middlewares/meta_request_handler.rb:11:in `call'
  pdfkit (0.5.4) lib/pdfkit/middleware.rb:16:in `call'
  actionpack (3.2.16) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  rack (1.4.5) lib/rack/etag.rb:23:in `call'
  rack (1.4.5) lib/rack/conditionalget.rb:25:in `call'
  actionpack (3.2.16) lib/action_dispatch/middleware/head.rb:14:in `call'
  actionpack (3.2.16) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  actionpack (3.2.16) lib/action_dispatch/middleware/flash.rb:242:in `call'
  rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
  rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
  actionpack (3.2.16) lib/action_dispatch/middleware/cookies.rb:341:in `call'
  activerecord (3.2.16) lib/active_record/query_cache.rb:64:in `call'
  activerecord (3.2.16) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
  actionpack (3.2.16) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  activesupport (3.2.16) lib/active_support/callbacks.rb:405:in `_run__572592932466143201__call__1542018980761186849__callbacks'
  activesupport (3.2.16) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.16) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  activesupport (3.2.16) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.16) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (3.2.16) lib/action_dispatch/middleware/reloader.rb:65:in `call'
  actionpack (3.2.16) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  better_errors (2.1.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (2.1.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (2.1.0) lib/better_errors/middleware.rb:57:in `call'
  rack-contrib (1.2.0) lib/rack/contrib/response_headers.rb:17:in `call'
  meta_request (0.3.4) lib/meta_request/middlewares/headers.rb:16:in `call'
  actionpack (3.2.16) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  actionpack (3.2.16) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.16) lib/rails/rack/logger.rb:32:in `call_app'
  railties (3.2.16) lib/rails/rack/logger.rb:16:in `block in call'
  activesupport (3.2.16) lib/active_support/tagged_logging.rb:22:in `tagged'
  railties (3.2.16) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.16) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.5) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.16) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.5) lib/rack/lock.rb:15:in `call'
  actionpack (3.2.16) lib/action_dispatch/middleware/static.rb:63:in `call'
  railties (3.2.16) lib/rails/engine.rb:484:in `call'
  railties (3.2.16) lib/rails/application.rb:231:in `call'
  rack (1.4.5) lib/rack/content_length.rb:14:in `call'
  railties (3.2.16) lib/rails/rack/log_tailer.rb:17:in `call'
  thin (1.5.1) lib/thin/connection.rb:81:in `block in pre_process'
  thin (1.5.1) lib/thin/connection.rb:79:in `pre_process'
  thin (1.5.1) lib/thin/connection.rb:54:in `process'
  thin (1.5.1) lib/thin/connection.rb:39:in `receive_data'
  eventmachine (1.0.3) lib/eventmachine.rb:187:in `run'
  thin (1.5.1) lib/thin/backends/base.rb:63:in `start'
  thin (1.5.1) lib/thin/server.rb:159:in `start'
  rack (1.4.5) lib/rack/handler/thin.rb:13:in `run'
  rack (1.4.5) lib/rack/server.rb:268:in `start'
  railties (3.2.16) lib/rails/commands/server.rb:70:in `start'
  railties (3.2.16) lib/rails/commands.rb:55:in `block in <top (required)>'
  railties (3.2.16) lib/rails/commands.rb:50:in `<top (required)>'
  script/rails:6:in `<main>'

似乎是什么问题?

2 个答案:

答案 0 :(得分:3)

我已按照以下步骤解决了问题:

  1. 删除meta_request
  2. 中的/tmp/data/文件夹
  3. 使用rails s
  4. 重启服务器

    现在一切正常:)

答案 1 :(得分:0)

由于 RailsPanel 是一个很棒的工具,请继续将它与 meta_request gem 一起使用,使用以下代码在文件 config/initializers/meta_request.rb 中创建 Rails 初始值设定项: >

if defined?(MetaRequest) && MetaRequest::Event.private_instance_methods(false).exclude?(:not_encodable?)
  MetaRequest::Event.class_eval do
    private

    def json_encodable(payload)
      return {} unless payload.is_a?(Hash)

      transform_hash(payload, deep: true) do |hash, key, value|
        if value.class.to_s == 'ActionDispatch::Http::Headers'
          value = value.to_h.select { |k, _| k.upcase == k }
        elsif not_encodable?(value)
          value = self.class.const_get(:NOT_JSON_ENCODABLE)
        end

        begin
          value.to_json(methods: [:duration])
          new_value = value
        rescue StandardError
          new_value = self.class.const_get(:NOT_JSON_ENCODABLE)
        end
        hash[key] = new_value
      end.with_indifferent_access
    end

    def not_encodable?(value)
      (defined?(ActiveRecord) && value.is_a?(ActiveRecord::ConnectionAdapters::AbstractAdapter)) ||
        (defined?(ActionDispatch) &&
          (value.is_a?(ActionDispatch::Request) || value.is_a?(ActionDispatch::Response)))
    end
  end
end
<块引用>

参考:https://github.com/dejan/rails_panel/pull/177#issuecomment-797378347