aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/json
diff options
context:
space:
mode:
authorGodfrey Chan <godfreykfc@gmail.com>2013-11-26 14:05:12 -0800
committerGodfrey Chan <godfreykfc@gmail.com>2013-12-02 17:22:57 -0800
commitfadc02b7322c97f10d34fc04c147f3585eda1272 (patch)
tree759cbc41156b95be670d4bb801f4b4f7c64175ed /activesupport/lib/active_support/json
parent23aa94a7b2d51536baa5eb91a8cd50cdd6dfa99e (diff)
downloadrails-fadc02b7322c97f10d34fc04c147f3585eda1272.tar.gz
rails-fadc02b7322c97f10d34fc04c147f3585eda1272.tar.bz2
rails-fadc02b7322c97f10d34fc04c147f3585eda1272.zip
Added back the `encode_big_decimal_as_string` option with warning
Also added the missing CHANGELOG entry for #12183 @ 80e7552073 and 4d02296cfb.
Diffstat (limited to 'activesupport/lib/active_support/json')
-rw-r--r--activesupport/lib/active_support/json/encoding.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/json/encoding.rb b/activesupport/lib/active_support/json/encoding.rb
index eb25ef7a4c..060dcb6995 100644
--- a/activesupport/lib/active_support/json/encoding.rb
+++ b/activesupport/lib/active_support/json/encoding.rb
@@ -5,6 +5,7 @@ module ActiveSupport
class << self
delegate :use_standard_json_time_format, :use_standard_json_time_format=,
:escape_html_entities_in_json, :escape_html_entities_in_json=,
+ :encode_big_decimal_as_string, :encode_big_decimal_as_string=,
:json_encoder, :json_encoder=,
:to => :'ActiveSupport::JSON::Encoding'
end
@@ -113,6 +114,32 @@ module ActiveSupport
# in +Object#to_json+ and +ActiveSupport::JSON.encode+.
attr_accessor :json_encoder
+ def encode_big_decimal_as_string=(as_string)
+ message = \
+ "The JSON encoder in Rails 4.1 no longer supports encoding BigDecimals as JSON numbers. Instead, " \
+ "the new encoder will always encode them as strings.\n\n" \
+ "You are seeing this error because you have 'active_support.encode_big_decimal_as_string' in " \
+ "your configuration file. If you have been setting this to true, you can safely remove it from " \
+ "your configuration. Otherwise, you should add the 'activesupport-json_encoder' gem to your " \
+ "Gemfile in order to restore this functionality."
+
+ raise NotImplementedError, message
+ end
+
+ def encode_big_decimal_as_string
+ message = \
+ "The JSON encoder in Rails 4.1 no longer supports encoding BigDecimals as JSON numbers. Instead, " \
+ "the new encoder will always encode them as strings.\n\n" \
+ "You are seeing this error because you are trying to check the value of the related configuration, " \
+ "'active_support.encode_big_decimal_as_string'. If your application depends on this option, you should " \
+ "add the 'activesupport-json_encoder' gem to your Gemfile. For now, this option will always be true. " \
+ "In the future, it will be removed from Rails, so you should stop checking its value."
+
+ ActiveSupport::Deprecation.warn message
+
+ true
+ end
+
# Deprecate CircularReferenceError
def const_missing(name)
if name == :CircularReferenceError