LoginSignup
0
0

More than 5 years have passed since last update.

サブディレクトリで動かしているErrbitのURLをAirbrakeに指定するときは最後にスラッシュをつけること

Posted at

rails g airbrake で生成した設定ファイルや、Errbit のアプリ登録後の画面には c.host = 'http://xxx.vs.sakura.ne.jp' のように表示されているので、最後にスラッシュをつけない流儀に合わせてサブディレクトリを書いたらとてもはまりました。

正しくは、次のように最後にスラッシュをつけるのが正しいです。そうしないと /errbit/api の形になってくれません。

config/initializers/airbrake.rb
Airbrake.configure do |c|
  c.host = 'http://xxx.vs.sakura.ne.jp/errbit/'
  c.project_id = 1
  c.project_key = 'xxxxxxxxxxxxxxxx'
end

該当個所のコード検証

スラッシュをつけないとこの2つ目のように /foo がなかったことになってしまう。

require "uri"
URI.join("http://example.net", "api").to_s      # => "http://example.net/api"
URI.join("http://example.net/foo", "api").to_s  # => "http://example.net/api"
URI.join("http://example.net/foo/", "api").to_s # => "http://example.net/foo/api"
0
0
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
0
0