"stack level too deep" with simple client - any advice?

25 views
Skip to first unread message

Carlos Eberhardt

unread,
Sep 19, 2011, 2:23:07 PM9/19/11
to rest...@googlegroups.com
Pardon my newbieness (both to Restfulie and Rails).

I'm getting a stack level too deep error when trying to unmarshal the response from Restfulie. It looks like it's a problem in methodize, but I've come up short with my research. Has anyone seen this before? I'd appreciate any tips at all. Thanks!

I'm on Mac OS X Lion with Rails 3.1.0 and ruby 1.8.7 (2010-01-10 patchlevel 249).

Here's what my rails console looks like:

ready to execute request using stack typeRestfulie::Client::Feature::BaseRequestargstypeRestfulie::Client::Feature::RescueExceptionargstypeRestfulie::Client::Feature::SetupHeaderargstypeRestfulie::Client::Feature::SerializeBodyargstypeRestfulie::Client::Feature::EnhanceResponseargstypeRestfulie::Client::Feature::FollowRequestargs
invoking filter Restfulie::Client::Feature::FollowRequest with #<Restfulie::Client::Dsl:0x105e59150> at 
invoking filter Restfulie::Client::Feature::EnhanceResponse with #<Restfulie::Client::Dsl:0x105e59150> at 
invoking filter Restfulie::Client::Feature::SerializeBody with #<Restfulie::Client::Dsl:0x105e59150> at 
invoking filter Restfulie::Client::Feature::SetupHeader with #<Restfulie::Client::Dsl:0x105e59150> at 
invoking filter Restfulie::Client::Feature::RescueException with #<Restfulie::Client::Dsl:0x105e59150> at 
invoking filter Restfulie::Client::Feature::BaseRequest with #<Restfulie::Client::Dsl:0x105e59150> at 
GET /items

=> #<Net::HTTPOK 200 OK  readbody=true>
>> puts h.body
[{"price":"12.99","name":"Blade Runner","created_at":"2011-09-18T20:36:36Z","category":"Movie","updated_at":"2011-09-18T20:36:36Z","id":1},{"price":"8.49","name":"The Long Goodbye","created_at":"2011-09-18T20:37:43Z","category":"Book","updated_at":"2011-09-18T20:37:43Z","id":2},{"price":"5.99","name":"One Fish Two Fish Red Fish Blue Fish","created_at":"2011-09-18T21:10:07Z","category":"Book","updated_at":"2011-09-18T21:10:07Z","id":3},{"price":"199.99","name":"iPhone 4","created_at":"2011-09-18T21:23:58Z","category":"Electronics","updated_at":"2011-09-18T21:23:58Z","id":4}]
=> nil
>> puts h.code
200
=> nil
>> items = h.resource
SystemStackError: stack level too deep
from /Library/Ruby/Gems/1.8/gems/methodize-0.2.0/lib/methodize.rb:30:in `method_missing'
from /Library/Ruby/Gems/1.8/gems/methodize-0.2.0/lib/methodize.rb:30:in `method_missing'
from /Library/Ruby/Gems/1.8/gems/methodize-0.2.0/lib/methodize.rb:9:in `extended'
from /Library/Ruby/Gems/1.8/gems/medie-1.0.0/lib/medie/json/driver.rb:19:in `extend'
from /Library/Ruby/Gems/1.8/gems/medie-1.0.0/lib/medie/json/driver.rb:19:in `unmarshal'
from /Library/Ruby/Gems/1.8/gems/restfulie-1.0.3/lib/restfulie/client/http/response_holder.rb:8:in `resource'
from (irb):4

Carlos Eberhardt

unread,
Sep 20, 2011, 12:25:47 PM9/20/11
to rest...@googlegroups.com
Sorry for the noise, I should've tried harder. Using RVM I think I fixed that problem. I'm still not able to get the client working quite like examples, however. It looks like I need to dig into the "resource" a bit more than I expected. I'm probably missing something simple.

Loading development environment (Rails 3.1.0)
ruby-1.8.7-p334 :001 > response = Restfulie.at('http://localhost:3000/items').get
ready to execute request using stack typeRestfulie::Client::Feature::BaseRequestargstypeRestfulie::Client::Feature::RescueExceptionargstypeRestfulie::Client::Feature::SetupHeaderargstypeRestfulie::Client::Feature::SerializeBodyargstypeRestfulie::Client::Feature::EnhanceResponseargstypeRestfulie::Client::Feature::FollowRequestargs
invoking filter Restfulie::Client::Feature::FollowRequest with #<Restfulie::Client::Dsl:0x10301c738> at 
invoking filter Restfulie::Client::Feature::EnhanceResponse with #<Restfulie::Client::Dsl:0x10301c738> at 
invoking filter Restfulie::Client::Feature::SerializeBody with #<Restfulie::Client::Dsl:0x10301c738> at 
invoking filter Restfulie::Client::Feature::SetupHeader with #<Restfulie::Client::Dsl:0x10301c738> at 
invoking filter Restfulie::Client::Feature::RescueException with #<Restfulie::Client::Dsl:0x10301c738> at 
invoking filter Restfulie::Client::Feature::BaseRequest with #<Restfulie::Client::Dsl:0x10301c738> at 
GET /items

 => #<Net::HTTPOK 200 OK  readbody=true> 
ruby-1.8.7-p334 :002 > items = response.resource
 => {"root"=>{"member"=>[{"price"=>"16.49", "name"=>"The Long Goodbye", "id"=>"1", "link"=>{"href"=>"http://localhost:3000/items/1", "rel"=>"self", "type"=>"application/xml"}}, {"price"=>"14.49", "name"=>"Bladerunner", "id"=>"2", "link"=>{"href"=>"http://localhost:3000/items/2", "rel"=>"self", "type"=>"application/xml"}}, {"price"=>"6.99", "name"=>"One Fish, Two Fish, Red Fish, Blue Fish", "id"=>"3", "link"=>{"href"=>"http://localhost:3000/items/3", "rel"=>"self", "type"=>"application/xml"}}], "link"=>{"href"=>"http://localhost:3000/baskets", "rel"=>"basket", "type"=>"application/xml"}}} 
ruby-1.8.7-p334 :003 > items[0].link
NoMethodError: undefined method `link' for nil:NilClass
from /Users/z024400/.rvm/gems/ruby-1.8.7-p334/gems/activesupport-3.1.0/lib/active_support/whiny_nil.rb:48:in `method_missing'
from (irb):3
ruby-1.8.7-p334 :004 > items["root"]["member"][0].link
 => {"href"=>"http://localhost:3000/items/1", "rel"=>"self", "type"=>"application/xml"} 
ruby-1.8.7-p334 :005 > 

Any advice on this is much appreciated!


Reply all
Reply to author
Forward
0 new messages