I am using ActiveResource against a non-Rails REST API… in fact even the “Rest” part is doubtful but they tried:
Although RESTful applications are ideally stateless, the ALM platform
requires sessions to manage locking, client life time, and perform
other basic tasks. Session management is performed using a cookie
named QCSession.
Anyway, I need to issue one GET to “authentication-point/authenticate” to get a user authenticated and take a cookie back. Just not sure how to do that. Here is what I have but I am getting a 404 error:
class AlmActiveResource < ActiveResource::Base
attr_accessor :lwsso_cookie, :qcsession_cookie
self.site = "http://alm_url/qcbin/"
self.user = "name"
self.password = "pw"
def self.authentication
@auth_point = "authentication-point/authenticate"
self.prefix(@auth_point)
meow = self.get(:authenticate)
Rails.logger.debug("Meow: #{meow.inspect}")
end
end
I had the exact same problem. I finally had to put everything in the controller to get it to talk to ALM. It’s not the best but it works. Here’s the Index action in the ReleaseCycles controller:
I created the get “getAuthenticatedCurl” in the ApplicationController. It looks like:
It’s not pretty but it works and it’s fast. My next step is to do the same thing as an ActiveResource. Hope it helps and good luck!