method

get

rails latest stable - Class: ActiveResource::Connection

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v3.2.13) is shown here.

get(path, headers = {})
public

Executes a GET request. Used to get (find) resources.

1Note

Passing in parameters

wiseleyb ยท Jan 5, 2011

If you want to pass in parameters you can do it like this:

User.get(:find_by_name, headers = {:name => "bob"})
=> /users/find_by_name.xml?name=bob

For nested routes...

routes.rb resources :companies do resources :users do member do get :find_by_name end end end

In your api code...

class User < ActiveResource::Base  

self.site = "/companies/:company_id"

def self.find_by_name(name, company_id)
  User.get(:find_by_name, headers = {:name => name, :company_id => company_id}
end
end

Then doing...

User.find_by_name("bob", 1)

Would call

companies/1/users/find_by_name.xml?name="bob"

This works in Rails 3.1 - not sure about older versions (specifically I think the routes were done differently in < 3