1

Anybody have any ideas? The situation is like this: I have a primary rails app and an auxiliary one. The auxiliary app is used to transform a web service request into a RESTful PUT to the main app. The resource the auxiliary app is attempting to add to requires authentication. Any ideas would be much appreciated! Thanks SO!

2 Answers 2

1

ActiveResource is used for this purpose:

class MyModel < ActiveResource::Base
  self.site = OTHER_APP_URL
  self.user = OTHER_APP_USER
  self.password = OTHER_APP_PASSWORD

  # Rest of the code here
end

Read up on how to talk to RESTful API from ActiveResource here: http://api.rubyonrails.org/classes/ActiveResource/Base.html

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Swan, I did not see your answer before adding my own. This would definitely work, and I almost resorted to HTTP authentication, however I found a way to leverage my current RESTful authentication scheme involving the RESTful_authentication and Curb gems.
I was discussing this issue with a friend of mine with more exp in RESTful webservices and argued that introducing state (via sessions) breaks the REST model which is why Rails undoubtedly provides such great mechanisms as the one you describe above.
0

I think I may have found my own answer by polling some of my IM contacts. The most logical approach is to use the Curb ruby gem. From the aforementioned API, one simply enables the cookie jar, restfully authenticates and then includes the cookie in subsequent HTTP actions requiring authentication ;)

(Will post some code when I get this implemented..)

Would still appreciate comments and or alternatives though!

1 Comment

ActiveResource is made for this purpose, provides a lot of utility methods and awesome abstraction. It is highly recommended. Thanks for the pointer on Curb though, I will surely check it out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.