Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
20
Help us understand the problem. What is going on with this article?
@kwappa

rack-mini-profilerをGemfileに入れるときは require: false しよう

More than 5 years have passed since last update.

tl;dr

rack-mini-profilerGemfile に入れるときは require: false しよう。

詳細

動く

デフォルトで有効になってるってのは多人数で開発してるといろいろよろしくないので、環境変数を指定して有効にするようにした。

  • Gemfile
group :development do
  gem 'rack-mini-profiler', '0.9.1', require: false
end
  • config/initializers/rack_profiler.rb
if Rails.env == 'development'
  if ENV.has_key?('ENABLE_RACK_PROFILER')
    require 'rack-mini-profiler'
    Rack::MiniProfilerRails.initialize!(Rails.application)
  end
end
  • rails server
% ENABLE_RACK_PROFILER=1 bundle exec rails server

動かない

  • Gemfile
group :development do
  gem 'rack-mini-profiler', '0.9.1'
end
  • config/initializers/rack_profiler.rb
if Rails.env == 'development'
  require 'rack-mini-profiler'
  Rack::MiniProfilerRails.initialize!(Rails.application)
end

これをしないと500が返る。原因は rack-mini-profiler が複数回 require されること。

undefined method `discard' for nil:NilClass rack-mini-profiler

backtrace。

[2014-06-11 11:48:42] ERROR NoMethodError: undefined method `discard' for nil:NilClass
/PATH/TO/YOUR/ruby/gems/2.0.0/gems/rack-mini-profiler-0.9.1/lib/mini_profiler/profiler.rb:307:in `call'

ググるとPRが引っかかるんだけど、「それは違うよ」というオチで、「idiot-proof」として(ぐぬぬ)別のPRがマージされている。

Links

20
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
kwappa
Ruby programmer

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
20
Help us understand the problem. What is going on with this article?