When using gon with Jbuilder and the key_format! :camelize :lower option, array database attributes are incorrectly parsed to json. Visiting the .json route displays the correctly parsed JSON from Jbuilder, but the JSON from Gon inside the <head> tag on the page is incorrect.
Example:
Attribute is stored in a database array attribute:
Jbuilder template uses the key_format! option to convert snake_case to camelCase:
_form.json.jbuilder
json.key_format! camelize: :lower
json.rules @rules do |rule|
json.(rule, :id)
json.conditionsAttributes rule.conditions do |condition|
json.(condition, :determinant_name, :condition_value, :operator)
end
end
When using gon with Jbuilder and the
key_format! :camelize :lower
option, array database attributes are incorrectly parsed to json. Visiting the .json route displays the correctly parsed JSON from Jbuilder, but the JSON from Gon inside the<head>
tag on the page is incorrect.Example:
Attribute is stored in a database array attribute:
schema.rb
Jbuilder template uses the
key_format!
option to convert snake_case to camelCase:_form.json.jbuilder
Expected result:
Actual result: