method
get
v3.2.1 -
Show latest stable
-
1 note -
Class: ActiveResource::Connection
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3 (0)
- 2.1.0 (0)
- 2.2.1 (0)
- 2.3.8 (0)
- 3.0.0 (1)
- 3.0.9 (-4)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1
- 6.1.7.7
- 7.0.0
- 7.1.3.2
- 7.1.3.4
- What's this?
Register or
log in
to add new notes.
wiseleyb -
January 5, 2011
0 thanks
Passing in parameters
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