rails脚本 script / performance / request 需要会话脚本,生成此会话脚本的最佳方法是什么?

有帮助吗?

解决方案

将此代码添加到application.rb文件

before_filter :benchmark_log

  def benchmark_log
   File.open("request_log.txt","a") do |f|
      f.puts request.method.to_s + " '" + request.request_uri + "', " + params.except(:action).except(:controller).inspect.gsub(/(^\{|\}$)/,"")
    end
  end

然后您可以在浏览器中访问多个页面,会话脚本将写入应用程序根目录中的request_log.txt文件

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top