5

I am using an ActiveResource model named "Setting" to connect to an external web service which delivers some response like the following example:

{"setting" => {"id" => 10, :details => {"10a" => 7, "10b" => 8}}}

The problem is, that ActiveResource tries to symbolize all keys in the details hash but this is not possible and raises a NameError: wrong constant name 10a. Is there any chance to prohibit the symbolication or even to avoid the transformation of details to a separate object?

Thanks

anka
  • 3,817
  • 1
  • 30
  • 36
  • What are you doing with the details hash? Is it just being processed, or are you saving it somewhere? – Solomon Aug 27 '12 at 22:52

2 Answers2

0

Have you tried to set your schema manually? I don't know if you can set nested attributes like this.

class Setting < ActiveResource::Base
   schema = {'setting' => {'id' => :integer, :details => {'10a' => :integer, '10b' => :integer}}}
end
basgys
  • 4,320
  • 28
  • 39
0

I'm assuming the separate object is a HashWithIndifferentAccess? Can you try calling #deep_stringify_keys on the details hash before using it?

RubeOnRails
  • 1,153
  • 11
  • 22