I had a similar problem. After a little research, I wrapped the as_json ActiveModel method with a helper that would haveh the hash keys. Then I would include the module in the appropriate model (s):
# lib/camel_json.rb module CamelJson def as_json(options) camelize_keys(super(options)) end private def camelize_keys(hash) values = hash.map do |key, value| [key.camelize(:lower), value] end Hash[values] end end
This worked very well for our situation, which was relatively simplified. However, if you are using JBuilder, apparently there is a setting to set the camel case to default: fooobar.com/questions/889595 / ...
source share