There is a built-in type called Data whose purpose is rather cryptic . You seem to stumble upon it:
$ ruby -e 'Data.new' -e:1:in `new': allocator undefined for Data (TypeError) from -e:1
Question: how did he get there? The last stack of frames places
here . Thus, it appears
Data , going from the call
find_or_create_resource_for . Perhaps the code branch looks like this:
$ irb >> class C >> end => nil >> C.const_get('Data') => Data
This makes me suspect that you have an attribute or similar floating object named :data or "data" , although you have not mentioned above. You? In particular, it looks like we have a JSON response with a sub-hash whose key is "data".
Here is a script that can trigger an error for the generated input, but not from the response you sent:
$ cat ./activeresource-oddity.rb #!/usr/bin/env ruby require 'rubygems' gem 'activeresource', '3.0.10' require 'active_resource' class User < ActiveResource::Base self.site = "http://localhost:3000/" self.element_name = "users" self.format = :json end USER = User.new :name => "Test", :email => " test.user@domain.com " def simulate_load_attributes_from_response(response_body) puts "Loading #{response_body}.." USER.load User.format.decode(response_body) end OK = '{"email":" test@gmail.com ","name":"test curl","admin":false,"uuid":"afb8c98b-562a-4603-bbe4-f8f0816cef0d","creation_limit":5}' BORKED = '{"data":{"email":" test@gmail.com ","name":"test curl","admin":false,"uuid":"afb8c98b-562a-4603-bbe4-f8f0816cef0d","creation_limit":5}}' simulate_load_attributes_from_response OK simulate_load_attributes_from_response BORKED
produces ..
$ ./activeresource-oddity.rb Loading {"email":" test@gmail.com ","name":"test curl","admin":false,"uuid":"afb8c98b-562a-4603-bbe4-f8f0816cef0d","creation_limit":5}.. Loading {"data":{"email":" test@gmail.com ","name":"test curl","admin":false,"uuid":"afb8c98b-562a-4603-bbe4-f8f0816cef0d","creation_limit":5}}.. /opt/local/lib/ruby/gems/1.8/gems/activeresource-3.0.10/lib/active_resource/base.rb:1233:in `new': allocator undefined for Data (TypeError) from /opt/local/lib/ruby/gems/1.8/gems/activeresource-3.0.10/lib/active_resource/base.rb:1233:in `load' from /opt/local/lib/ruby/gems/1.8/gems/activeresource-3.0.10/lib/active_resource/base.rb:1219:in `each' from /opt/local/lib/ruby/gems/1.8/gems/activeresource-3.0.10/lib/active_resource/base.rb:1219:in `load' from ./activeresource-oddity.rb:17:in `simulate_load_attributes_from_response' from ./activeresource-oddity.rb:24
If I were you, I would open /Library/Ruby/Gems/1.8/gems/activeresource-3.0.10/lib/active_resource/base.rb , find load_attributes_from_response on line 1320 and temporarily change
load(self.class.format.decode(response.body))
to
load(self.class.format.decode(response.body).tap { |decoded| puts "Decoded: #{decoded.inspect}" })
.. and reproduce the error again to see what really comes out of your json decoder.