我正在尝试找到使用 Ruby 在 Redmine 中的问题之间插入新关系的语法。
我一直在尝试的代码:
require 'rubygems'
require 'active_resource'
class Issue < ActiveResource::Base
self.site = '[the site]'
self.user = '[the user]'
self.password = '[the password]' #not hard coded
self.format = :json #I've had issues with Issue.find(i) without explicitly stating the format
end
class IssueRelation < ActiveResource::Base
self.site = '[the site]'
self.user = '[the user]'
self.password = '[the password]' #not hard coded
self.format = :json #I've had issues with Issue.find(i) without explicitly stating the format
end
issue1 = Issue.find(1)
issue2 = Issue.find(2)
puts issue1.id
puts issue2.id
relation = IssueRelation.new(
:issue => issue1,
:issue_to => issue2,
:relation_type => 'relates'
)
if relation.save
puts relation.id
else
puts relation.errors.full_message
end
我得到的输出:
1
2
...'handle_response': Failed. Response code = 404. Response Message = not found.
输出表明已成功找到问题 1 和 2,但我用于关系的名称无效,因此未找到 404。
鉴于我发现了它会链接的两个问题,在 Redmine 的 API 中创建关系的正确语法是什么?