· 1 min read

Screencast: MiniProfiler

Downloads in verschiedenen Formaten:

mp4 m4v webm ogg

Resourcen:

Gemfile

[ruby]

gem ‘rack-mini-profiler’ [/ruby]

products/index.html.erb

[html] <%= pluralize project.tasks.size, “task” %> [/html]

projects_controller.rb

[ruby]

@projects = Project.order(:created_at).select(“projects.*, count(tasks.id) as tasks_count”).joins(“left outer join tasks on project_id=projects.id”).group(“projects.id”) Rack::MiniProfiler.step(“fetch projects”) do @projects.all end [/ruby]

config/environments/production.rb

[ruby]

config.serve_static_assets = true [/ruby]

terminal

[bash] rake assets:precompile rake db:setup RAILS_ENV=production rails s -e production [/bash]

application_controller.rb

[ruby]

before_filter :miniprofiler

private

def miniprofiler Rack::MiniProfiler.authorize_request # if user.admin? end [/ruby]

Back to Blog