Project

General

Profile

Redmine ruby rest API error `instantiate_collection': undefined method `collect!'

Added by Yecine Yecine over 12 years ago

Hi,

I have just installed redmine 1.2.2 and i wanted to use the ruby rest api but i have some problems...

I have used one of the example in the documentation and i have offcourse changed the url site, user and password

require 'rubygems'
require 'active_resource'

# Issue model on the client side
class Issue < ActiveResource::Base
  self.site = 'http://redmine.server/'
  self.user = 'admin'
  self.password = 'test'
end

# Retrieving issues
issues = Issue.find(:all)
puts issues.first.subject

But when i run this code i have the following error :

/Users/yecine/.rvm/gems/ruby-1.9.2-p290@global/gems/activeresource-3.1.2/lib/active_resource/base.rb:930:in `instantiate_collection': undefined method `collect!' for #<Hash:0x007fca1991c3d8> (NoMethodError)
    from /Users/yecine/.rvm/gems/ruby-1.9.2-p290@global/gems/activeresource-3.1.2/lib/active_resource/base.rb:902:in `find_every'
    from /Users/yecine/.rvm/gems/ruby-1.9.2-p290@global/gems/activeresource-3.1.2/lib/active_resource/base.rb:814:in `find'
    from /Users/yecine/Documents/github/redmine_lighthouse_sync/redmine_project_sync.rb:14:in `<main>'

Is the rest api working with ruby in 1.2.2 ?
Someone can help me on this ?

Thanks


Replies (9)

RE: Redmine ruby rest API error `instantiate_collection': undefined method `collect!' - Added by Yecine Yecine over 12 years ago

if seems that there is an error with the json output format ... it's returning a hash and the active ressource is waiting for an array ...

I changed to xml format and it's working ...

class Issue < ActiveResource::Base
  self.site = 'http://redmine.server/'
  self.user = 'admin'
  self.password = 'test'
  self.format = :xml
end

RE: Redmine ruby rest API error `instantiate_collection': undefined method `collect!' - Added by Etienne Massip over 12 years ago

Redmine does not support neither Ruby 1.9 nor RoR 3.x ATM, see RedmineInstall.

RE: Redmine ruby rest API error `instantiate_collection': undefined method `collect!' - Added by Etienne Massip over 12 years ago

Etienne Massip wrote:

Redmine does not support neither Ruby 1.9 nor RoR 3.x ATM, see RedmineInstall.

Just forget about this answer.

RE: Redmine ruby rest API error `instantiate_collection': undefined method `collect!' - Added by Yecine Yecine over 12 years ago

For info

About your application's environment
Ruby version 1.8.7 (i686-linux)
RubyGems version 1.6.0
Rack version 1.1.2
Rails version 2.3.11
Active Record version 2.3.11
Active Resource version 2.3.11
Action Mailer version 2.3.11
Active Support version 2.3.11
Application root /home/.sites/28/site1/vhosts/redmine/htdocs
Environment production
Database adapter mysql
Database schema version 20110902000000

About your Redmine plugins
Redmine Backlogs v0.6.20

RE: Redmine ruby rest API error `instantiate_collection': undefined method `collect!' - Added by Yecine Yecine over 12 years ago

yes with :json i have the same problem ...

for now i'm using xml ...

RE: Redmine ruby rest API error `instantiate_collection': undefined method `collect!' - Added by Christian Baus over 11 years ago

self.format = :xml

fixed for me :)

working with rails-3.2.5 and ruby 1.9.2

RE: Redmine ruby rest API error `instantiate_collection': undefined method `collect!' - Added by James Lin over 9 years ago

Still has this issue.

redmine 2.5.2 + rails 3.2.19 + ruby 2.0.0

self.format = :xml fix this, But I don't like XML.

Looks like it is rails's fault?

    (1-9/9)