This project is archived and is in readonly mode.

#2305 ✓resolved
GrzesF

ActiveResource load method dies on Array contains Numeric elements

Reported by GrzesF | March 20th, 2009 @ 11:50 PM | in 2.x

Here is sample json which cause problem for ActiveResource load method:


{"id":13679082001,"referenceId":"homepage_main","name":"Main Video Homepage","shortDescription":null,
"videoIds":[13451141001,13460674001,13451144001,13460676001],"thumbnailURL":null,"filterTags":null,"playlistType":"EXPLICIT"}

The main problem is with Array element "video_ids":[13451141001,13460674001,13451144001,13460676001] while processing.
Load method raise exception:
ArgumentError: expected an attributes Hash, got 13451141001 
	from /Library/Ruby/Gems/1.8/gems/activeresource-2.3.2/lib/active_resource/base.rb:942:in `load'
	from /Library/Ruby/Gems/1.8/gems/activeresource-2.3.2/lib/active_resource/base.rb:655:in `initialize'
	from /Library/Ruby/Gems/1.8/gems/activeresource-2.3.2/lib/active_resource/base.rb:949:in `new'
	from /Library/Ruby/Gems/1.8/gems/activeresource-2.3.2/lib/active_resource/base.rb:949:in `load'
	from /Library/Ruby/Gems/1.8/gems/activeresource-2.3.2/lib/active_resource/base.rb:949:in `map'
	from /Library/Ruby/Gems/1.8/gems/activeresource-2.3.2/lib/active_resource/base.rb:949:in `load'
	from /Library/Ruby/Gems/1.8/gems/activeresource-2.3.2/lib/active_resource/base.rb:944:in `each'
	from /Library/Ruby/Gems/1.8/gems/activeresource-2.3.2/lib/active_resource/base.rb:944:in `load'
	from /Library/Ruby/Gems/1.8/gems/activeresource-2.3.2/lib/active_resource/base.rb:655:in `initialize'
	from /Library/Ruby/Gems/1.8/gems/activeresource-2.3.2/lib/active_resource/base.rb:603:in `new'
	from /Library/Ruby/Gems/1.8/gems/activeresource-2.3.2/lib/active_resource/base.rb:603:in `instantiate_record' 

I think there should be additional case when there are Numeric elements in Array child. I assume json file is in valid format.

Is it a bug ? or am I wrong ? I've added some test to this case and made a patch(attached). It works for me.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket