Using the iCyte API with Ruby on Rails

It is straightforward to connect to the iCyte API web server using the ActiveResource model in Rails. If you define (in config/environment.rb):

config.active_resource.site = "http://www.icyte.com/api/"
config.active_resource.user = 'user@example.com'
config.active_resource.password = 'password'

(substituting in your username and password), you can then define the following three models:

class Cyte < ActiveResource::Base; end
class Project < ActiveResource::Base; end
class User < ActiveResource::Base; end

You can then start interacting with the iCyte server immediately. For example:

$ ruby script/console
>> cytes = Cyte.find :all
=> [#<Cyte: ...]
>> cytes.first.title
=> "An Example Cyte"

To use parameters, simply pass them in as the parameters variable:

$ ruby script/console
>> cytes = Cyte.find :all, :params => {:filter => {:project_id => 969764153}}
=> [#<Cyte: ...]

To use a named action, do the following, for example:

$ ruby script/console
>> project = Project.find 969764153
>> project.get(:users)

See api.rubyonrails.org/classes/ActiveResource/Base.html for more information.