Ruby on Rails Monday, May 18, 2015

Hello,

I want to call a REST API with active resource, described here:
http://www.redmine.org/projects/redmine/wiki/Rest_api_with_ruby

this is my code:
require 'active_resource'

class Issue < ActiveResource::Base
  ActiveResource::Base.include_root_in_json = true
  self.site = 'http://demo.redmine.org/'
end

# Retrieving issues
issue = Issue.find(:all)

and getting this error:
/activeresource-4.0.0/lib/active_resource/base.rb:1327:in `load': expected an attributes Hash, got ["issues", [{"id"=>91663, "project"=>{"id"=>77006, "name"=>"proj1"},....

The link mentions:
You may need to set include_root_in_json = true in your ActiveResource class

But I don't understand where and how.
Greatly appreciate your help.

Cheers,
Peter

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0cf1a95b-e532-440f-858a-0f0a544e7a5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment