Skip to content

Instantly share code, notes, and snippets.

@tyabe
Created November 10, 2013 15:41
Show Gist options
  • Save tyabe/7399695 to your computer and use it in GitHub Desktop.
Save tyabe/7399695 to your computer and use it in GitHub Desktop.
This patch is a thing to be use the BetterErrors in Padrino 0.11 or later. Because, BettorErrors's XHR prevent by rack-protection.
# This file in a config directory.
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 in a lib directory.
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