Rack mini profiler
Add rack-mini-profiler to profile your Rails applications
Used 22 times
J
Julian Rubisch
Usage
This byte will add rack-mini-profiler, and will ask you whether you want to install some optional profiler dependencies
Run this command in your Rails app directory in the terminal:
rails app:template LOCATION="https://railsbytes.com/script/zNPsje"
Template Source
Review the code before running this template on your machine.
gem 'rack-mini-profiler'
# For memory profiling
gem 'memory_profiler' if yes?('add memory_profiler?')
# For call-stack profiling flamegraphs
gem 'flamegraph' if yes?('add flamegraph?')
gem 'stackprof' if yes?('add stackprof?')
run 'bundle'
if yes?('add authorization block for production?')
inject_into_file 'app/controllers/application_controller.rb', after: 'class ApplicationController < ActionController::Base
' do <<-RUBY
before_action do
if current_user && current_user.admin?
Rack::MiniProfiler.authorize_request
end
end
RUBY
end
end