Help us understand the problem. What is going on with this article?

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

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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした