Last active
November 10, 2015 09:31
-
-
Save kml/3395d73d874b0c302224 to your computer and use it in GitHub Desktop.
Remove circular references protection in ActiveSupport::JSON::Encoding::Encoder
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
# encoding: utf-8 | |
# Source: https://gist.github.com/kml/3395d73d874b0c302224 | |
# https://github.com/rails/rails/blob/3-2-stable/activesupport/lib/active_support/json/encoding.rb | |
require "active_support/json/encoding" | |
unless defined?(ActiveSupport::JSON::Encoding::CircularReferenceError) | |
abort "#{__FILE__}: CircularReferenceError is not defined. Remove this patch!" | |
end | |
# https://github.com/rails/rails/commit/798881ecd4510b9e1e5e10529fc2d81b9deb961e | |
# | |
# "[...] circular reference protection in as_json has been removed and the corresponding error class has been deprecated. | |
# As discussed with @jeremy, circular reference error | |
# *is considered programmer errors* | |
# and protecting against it is out of scope for the encoder." | |
module ActiveSupport | |
module JSON | |
module Encoding | |
class Encoder | |
private | |
def check_for_circular_references(value) | |
yield | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment