LoginSignup
11
9

More than 5 years have passed since last update.

dockerで立ち上げたrailsサーバでもBetter Errorsを使えるようにする

Posted at

dockerコンテナ内で起動しているrailsで exit 記述してもBetter Errorsが動いてくれなかったので修正します。

解決方法

以下のconfigをつくってrails server再起動するだけ :ok_hand:

config/environments/development.rb
if Rails.env.development?
  BetterErrors::Middleware.allow_ip! "0.0.0.0/0"
end

Better Errorsはdevelopmentでしか使っていないはずなのでenvで条件つけるの忘れないように。

ちなみに

docker-composeでrails serverを起動するときにbindingしていますよね。

docker-compose.yml
version: '3'
services:
  db:
    ...
  web:
    build: .
    command: bundle exec rails s -p 3000 -b '0.0.0.0'
    volumes:
      - .:/rails
    ports:
      - "3000:3000"
    depends_on:
      - db

以上です :wave:

参考

11
9
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
11
9