A couple of this that will hopefully get you on the right track:
- What you’re looking for is ActiveResource. This is explained in
documentation so I won’t go into a lot of detail here.
- Your example (getName()) is actually not in-line with the REST
architecture. Let me explain.
REST (especially as it is approached in Rails) is all about resources
and using the REST verbs to access them. I’m guessing that name is not
actually a resource in your application that you would “get.” Also, in
a RESTful application the verb “get” would not appear in your method
The more likely case is that “name” would be an attribute of some
resource, say “Person.” Then you would access people though the
RESTful resource URLs by applying the proper verb (GET, POST, PUT,
So if you wanted to get all the people you would send a GET request to
the “http://mydomain.com/people” URL, which would return a result in a
given format (HTML by default). For use by a client application the
format would typically be XML. So to ask the resource for XML format
you would access the “http://mydomain.com/people.xml” URL.
Now if you want to access a specific resource id you would send a GET
to the “http://mydomain.com/people/25” url or "“http://mydomain.com/
To perform the other operations on the resource you use the same URLs,
but instead use the appropriate verb. For example send a POST request
to the same “collection” URL “http://mydomain.com/people” to create a
new person. Send a “member” URL "“http://mydomain.com/people/25” a PUT
request to update it’s attributes or a DELETE request to destroy it.
As I mentioned in #1 above: ActiveResource knows about all this, and
allows you to access your remote resources almost exactly like you
would access them with ActiveRecord.
On May 12, 1:21 am, Sameera G. [email protected]