What is the best way to create a script to use with the rails request profiler?
-
02-07-2019 - |
Question
The rails scirpt script/performance/request
require a session script, what is the best way to generate this session script?
Solution
Add this code to your application.rb file
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
Then you can visit several pages in your browser, and the session script will be written into the request_log.txt file in your applications root directory
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow