23
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2014-06-11

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

23
22
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?