zh / redmine_importer

Redmine importer that works with trunk.
https://github.com/leovitch/redmine_importer/wiki
48 stars 57 forks source link

Error updating existing issues, Redmine 3.1 (solved) #36

Closed sbriand closed 8 years ago

sbriand commented 8 years ago

I was not able to update existing issue during import.

In the file production.log in the folder \redmine\log, I noticed the error :

NoMethodError (undefined method `project_id' for #<Issue::ActiveRecord_Relation:0x0000000f0c64a8>):
  lib/redmine/sudo_mode.rb:63:in `sudo_mode'

After investigation and debugging session, I have located the problem in the file importer_controller.rb, line 141

140   if unique_attr == "id"
141       issues = [Issue.where(:id => attr_value)]
142   else

The type of the array "issues" is Issue::ActiveRecord_Relation, instead of Issue, which I whould expect. That is the reason why, afterward, I get the error undefined method `project_id'.

Solution : I have modified the source code as follow.

140   if unique_attr == "id"
141       issues = Issue.where(:id => attr_value).to_a
142   else

It is working normally now.

Utopism commented 8 years ago

I had the same issue thanks for the fix

zh commented 8 years ago

In fact the current version of the code is (missing .first in the code above):

issues = [Issue.where(:id => attr_value).first]

should be OK.