ActiveResource and RESful edit

I'd like to know how to have ActiveResource generate a URL for the


type of resource.

I've got custom_methods.rb and have used


This generates


But all I get returned is a hash of the attributes (in this case of
team 1), rather than an object of team 1.

In other words the <team></team> tags aren't there.

Is this right?


That depends entirely on your edit action in your controller. Keep in
mind, ActiveResource won't give you raw XML back, it will return
resource objects.

OK, the controller on the resource is simply:

def edit
    @team = Team.find(params[:id])
    render :xml => @venture.to_xml

Which creates the xml, but all I have back in the client is a hash,


not the resource object I expected, like,

Team:object_id @prefix_options=(), @attributes={"foo"=>"bar"}



You're returning a venture. Do you have a resource for it? I'm not
even sure what the custom actions are supposed to return. I'd go by
the source or the unit tests to see if you're getting the expected

Darn, that should read

render :xml => @team.to_xml

Really this is scaffold code. As basic as it can get.

I've just read ActiveResource custom_method.rb more closely. Re:

# Person.get(:active) #=> [{:id => 1, :name => 'Ryan'}, {:id =>
2, :name => 'Joe'}]

Looks like I'm getting exactly what I should expect to get.

This isn't really very helpful. All I want to do is understand all
the relevant ways to interact with the standard ActiveRecord RESTful
API. Once I've got it figured I'll post, promise.

IIRC, #get/post/put/delete are lower level than what you're wanting. Try #find

Person.find(:all, :from => :active)
Person.find(:one, :from => '/companies/5/manager.xml')

Also, #edit will usually be a browser-only action for displaying a
form. There's no "XML forms", so the data from #show should be

@person = Person.find(1)
@person.age = 21