I would like to use the ActiveSupport
option encode_big_decimal_as_string
on one of my models. Should I put it in the model? Do I call this method on a model instance? Do I place this somewhere in config? What is an ActiveSupport
option and how could I use it?
Neither of these answers worked for me in Rails 4.0. Here is what works in Rails 4.0:
ActiveSupport::JSON::Encoding.encode_big_decimal_as_string = false
Add that line to your application config, like so:
# config/application.rb
...
module AppName
class Application < Rails::Application
...
ActiveSupport::JSON::Encoding.encode_big_decimal_as_string = false
...
end
end
As @tyler-nguyen said, this is being deprecated in Rails 4.1, and extracted into this gem: ActiveSupport JSON Encoder. Refer to the gem documentation for configuration in 4.1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With