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
19
Help us understand the problem. What is going on with this article?
@tyabe

Padrino で Better Errors を使う

More than 5 years have passed since last update.

better_errors は sinatra でも使えるので、何も難しいことはないですね。

$ ruby -v
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin11.4.2]
$ padrino -v
Padrino v. 0.10.7

サクッと Gemfile に追加して…

Gemfile
group :development do
  gem "better_errors"
  gem "binding_of_caller"
end
$ bundle install

パパッと設定を書いて上げれば…

config/boot.rb
# …
# Load our dependencies
equire 'rubygems' unless defined?(Gem)
require 'bundler/setup'
Bundler.require(:default, PADRINO_ENV)

# ココを追加
if Padrino.env == :development
  Padrino::Application.use BetterErrors::Middleware
  BetterErrors.application_root = PADRINO_ROOT
  BetterErrors.logger = Padrino.logger
  # 表示を許可するアクセス元 IPの指定
  # thanks! @dayflower
  # BetterErrors::Middleware.allow_ip! "127.0.0.0/8" # default
  # BetterErrors::Middleware.allow_ip! "::1/128"     # default
end

##
# ## Enable devel logging
#
# ...

リッチなエラーページが Padrino にもやってきて便利ですね!

追記:
Padrino 0.11 では protect_from_csrf が有効になっているため、
画面右側の情報が何も表示されなくなってしまっています。
どうやって解消すればいいかな…

回避方法を書いてみました。Padrino 0.11 以降で Better Errors を使う

19
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
tyabe
Rubyが好きなソフトウェアエンジニア。Shibuya.rb
storesjp
インターネットビジネスの企画・開発・運営、マーケティング、プロモーション、コンテンツの企画・制作

Comments

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