Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: c62cb2f2fb
Fetching contributors…

Cannot retrieve contributors at this time

35 lines (23 sloc) 1.247 kb

Active Resource Basics

This guide should provide you with all you need to get started managing the connection between business objects and RESTful web services. It implements a way to map web-based resources to local objects with CRUD semantics.


WARNING. This Guide is based on Rails 3.0. Some of the code shown here will not work in earlier versions of Rails.


Active Resource allows you to connect with RESTful web services. So, in Rails, Resource classes inherited from ActiveResource::Base and live in app/models.

Configuration and Usage

Putting Active Resource to use is very similar to Active Record. It’s as simple as creating a model class
that inherits from ActiveResource::Base and providing a site class variable to it:

class Person < ActiveResource::Base = “”

Now the Person class is REST enabled and can invoke REST services very similarly to how Active Record invokes
life cycle methods that operate against a persistent store.

  1. Find a person with id = 1
    ryan = Person.find(1)
    Person.exists?(1) # => true


Jump to Line
Something went wrong with that request. Please try again.