У меня была точно такая же проблема. Мне, наконец, пришлось поместить все в контроллер, чтобы заставить его общаться с ALM. Это не самое лучшее, но это работает. Вот действие Index в контроллере ReleaseCycles:
def index
conn=getAuthenticatedCurl
conn.url="#{$HPQC_REST_URL}/release-cycles"
conn.perform
results=conn.response_code
hash=Hash.from_xml(conn.body_str)
respond_to do |format|
format.html { render :xml => hash }
format.xml { render :xml => hash }
format.json { render :json => hash }
end
conn.url=$HPQC_LOGOUT_URL
conn.perform
conn.close
return results
end
Я создал get "getAuthenticatedCurl" в ApplicationController. Похоже:
$HPQC_HOST = "http://<your_alm_server>:8080"
$HPQC_REST_URL = "#{$HPQC_HOST}/qcbin/rest/domains/<DOMAIN>/projects/<PROJECT>"
$HPQC_LOGIN_URL = "#{$HPQC_HOST}/qcbin/authentication-point/authenticate"
$HPQC_LOGOUT_URL = "#{$HPQC_HOST}/qcbin/authentication-point/logout"
def getAuthenticatedCurl
@_conn = Curl::Easy.new($HPQC_LOGIN_URL)
@_conn.verbose = true
@_conn.http_auth_types = :basic
@_conn.userpwd = '<username>:<password>'
@_conn.enable_cookies = true
@_conn.cookiejar = 'cookies.txt'
@_conn.perform #creates the first cookie instance, which allows subsequent calls to the HPQC API
puts "connected...."
return @_conn
end
Это не красиво, но работает и быстро. Мой следующий шаг - сделать то же самое, что и ActiveResource. Надеюсь, это поможет и удачи!