Skip to content
Activeforce provides a simple to use and extend interface to Salesforce using the REST API
Find file
New pull request
Latest commit 82fd3c9 @amutz amutz Merge pull request #8 from appfolio/hexUseMinitest
Activeforce use travis and minitest


Gem Version Build Status

Activeforce provides a clean ActiveRecord-like interface to the REST API.

  • Detects the schema of the SalesForce Objects on the fly, so that you can interact with the familiar ActiveRecord style attribute accessor methods.
  • Provides full access to all methods provided to the SQL-like Salesforce Object Query Language (SOQL).
  • Integrates with REST-based BULK API.


Simple Usage

Salesforce.configure do
  username ""
  password "salesforcepassword"

The password is a combination of your salesforce password and the API Token

Specifying a particular API version

By default, activeforce uses version 22 of the Salesforce REST API. To specify another version:

Salesforce.configure do
  username ""
  password "salesforcepasswordapitoken" # This should be your salesforce password + your API Token
  api_version 18

Using the Sandbox

Salesforce.configure do
  username ""
  password "salesforcepassword"


activeforce provides implementation for some standard Salesforce Objects like Account, Contact, Opportunity, etc

Accessing custom objects

activeforce provides an easy way to declare models for custom objects or other SalesForce objects that are not included by default.

class Salesforce::CustomObject < Salesforce::Base
  self.custom_object = true

# or 

class Salesforce::Feed < Salesforce::Base

Find all objects


Find Account by id


Dynamic Finders


Specifying conditions|StartTopic=Content%2Fsforce_api_calls_soql.htm|SkinName=webhelp

Salesforce::Account.find(:all, :conditions => ":name = :value", :value => "my special name") 
# Issues a SOQL query to search for all Account objects where the field 'Name' matches "my special name"
# The SOQL Query is SELECT Id,Name,... FROM Account WHERE Name = 'my special name'
# This method of specifying columns in the query handles custom columns as well.
Salesforce::Account.find(:all, :conditions => ":account_type = :value", :value => "Special")
# The SOQL Query issued here is  SELECT Id,Name,... FROM Account WHERE Account_Type__c = 'Special'

Creating and Updating Objects

Deleting Objects

Salesforce Bulk API

You can create and schedule a job by:

job = Salesforce::Account.bulk_update do
  batch do
    record account_1 # account_1 is an object of type Salesforce::Account
    record account_2 # account_1 is an object of type Salesforce::Account

You can specify the columns that you want to update job = Salesforce::Account.bulk_update(:name, :website) do batch do record account_1 # account_1 is an object of type Salesforce::Account record account_2 # account_1 is an object of type Salesforce::Account end end

Contributing to activeforce

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.


Copyright (c) 2012 AppFolio, Inc.. See LICENSE.txt for further details.

Something went wrong with that request. Please try again.