Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Allows for per-user credentials for ActiveResource connections

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 example
Octocat-spinner-32 .gitignore
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README
Octocat-spinner-32 Rakefile
Octocat-spinner-32 init.rb
Octocat-spinner-32 install.rb
Octocat-spinner-32 uninstall.rb
README
HasOneAuthenticatedResource
=========================

This plugin allows you to access resources using ActiveResource without needing a static single set of credentials.  Credentials can be pulled in from the database (or anywhere else) and can be different depending on the model instance doing the request.

Example
=======

create_table :accounts, do |t|
  t.string   "tracker_token"
  t.string   "tempo_user"
  t.string   "tempo_password"
  t.string   "blinksale_user"
  t.string   "blinksale_password"
  t.string   "highrise_token"
  t.timestamps
end


class Account < ActiveRecord::Base
  has_one_authenticated_resource :tracker_projects, :headers => { 'X-TrackerToken' => :tracker_token }
  has_one_authenticated_resource :tracker_stories,  :headers => { 'X-TrackerToken' => :tracker_token }
  
  has_one_authenticated_resource :tempo_entries,  :user => :tempo_user, :password => :tempo_password
  has_one_authenticated_resource :tempo_projects, :user => :tempo_user, :password => :tempo_password
  has_one_authenticated_resource :tempo_reports,  :user => :tempo_user, :password => :tempo_password
  
  has_one_authenticated_resource :highrise_emails, :site => :highrise_site
  has_one_authenticated_resource :highrise_kases,  :site => :highrise_site
  
  has_one_authenticated_resource :blinksale_invoices, :user => :blinksale_user, :password => :blinksale_password
  has_one_authenticated_resource :blinksale_clients, :user => :blinksale_user, :password => :blinksale_password

  private
  def highrise_site
    "http://#{self.highrise_token}.highrisehq.com/"
  end
  
end

#find all the tracker projects that the credentials for the first account have access to
Account.first.tracker_projects.find(:all)


Copyright (c) 2010 Expected Behavior, released under the MIT license

# need to deal with belongs_to
Something went wrong with that request. Please try again.