Flowdock
find(*arguments) public

Core method for finding resources. Used similarly to Active Record's find method.

Arguments

The first argument is considered to be the scope of the query. That is, how many resources are returned from the request. It can be one of the following.

  • :one - Returns a single resource.
  • :first - Returns the first resource found.
  • :last - Returns the last resource found.
  • :all - Returns every resource that matches the request.

Options

  • :from - Sets the path or custom method that resources will be fetched from.
  • :params - Sets query and \prefix (nested URL) parameters.

Examples

  Person.find(1)
  # => GET /people/1.xml

  Person.find(:all)
  # => GET /people.xml

  Person.find(:all, :params => { :title => "CEO" })
  # => GET /people.xml?title=CEO

  Person.find(:first, :from => :managers)
  # => GET /people/managers.xml

  Person.find(:last, :from => :managers)
  # => GET /people/managers.xml

  Person.find(:all, :from => "/companies/1/people.xml")
  # => GET /companies/1/people.xml

  Person.find(:one, :from => :leader)
  # => GET /people/leader.xml

  Person.find(:all, :from => :developers, :params => { :language => 'ruby' })
  # => GET /people/developers.xml?language=ruby

  Person.find(:one, :from => "/companies/1/manager.xml")
  # => GET /companies/1/manager.xml

  StreetAddress.find(1, :params => { :person_id => 1 })
  # => GET /people/1/street_addresses/1.xml
Show source
Register or log in to add new notes.