Created
September 1, 2013 09:10
-
-
Save tyabe/6403230 to your computer and use it in GitHub Desktop.
Padrino 0.11 以降で Better Errors を使う ref: http://qiita.com/tyabe/items/b5300572a9dfd7f7e039
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Sample | |
class App < Padrino::Application | |
#... | |
set :protect_from_csrf, except: %r{/__better_errors/\d+/\w+\z} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if Padrino.env == :development | |
# Setup better_errors | |
Padrino::Application.use BetterErrors::Middleware | |
BetterErrors.application_root = PADRINO_ROOT | |
BetterErrors::Middleware.allow_ip! ENV['TRUSTED_IP'] if ENV['TRUSTED_IP'] | |
Padrino::Application.set :exclude_from_protection, '/__better_errors' # Append this | |
# ... | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if Padrino.env == :development | |
module Rack | |
module Protection | |
class AuthenticityToken | |
def accepts_with_allowed_path?(env) | |
if defined?(Padrino::Application.exclude_from_protection) | |
[Padrino::Application.exclude_from_protection].flatten.each do |path| | |
return true if Regexp.new(path).match(env['REQUEST_PATH']) | |
end | |
end | |
accepts_without_allowed_path?(env) | |
end | |
alias_method_chain :accepts?, :allowed_path | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment