Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

110 lines (86 sloc) 4.078 kB


A gem that provides a Salesforce Adapter for DataMapper 0.10.x. There are older versions of dm-salesforce specifically for 0.9.x.

The WSDL is automatically converted into Ruby classes upon the first invocation of the dm-salesforce adapter. The classes in turn get cached locally in one of the following locations, in order of precedence:

:repositories:salesforce:apidir (see included database.yml-example)

It should just work if you have the WSDL file. Directions for getting going are outlined below.

A quick example of using the adapter (schema differences withstanding):

class Account
  include DataMapper::Salesforce::Resource

  def self.default_repository_name

  # Old method for stipulating which fields are Salesforce-style IDs.  Alternatively,
  # can use the Salesforce-specific Serial custom DM type (see next model).
  def self.salesforce_id_properties

  property :id,          String, :key => true
  property :name,        String
  property :description, String
  property :fax,         String
  property :phone,       String
  property :type,        String
  property :website,     String
  property :is_awesome,  Boolean

  has 0..n, :contacts

class Contact
  include DataMapper::Salesforce::Resource

  def self.default_repository_name

  property :id,         Serial
  property :first_name, String
  property :last_name,  String
  property :email,      String

  belongs_to :account

DataMapper.setup(:salesforce, {:adapter  => 'salesforce',
                               :username => '',
                               :password => 'skateboardsf938915c9cdc36ff5498881b',
                               :path     => '/path/to/wsdl.xml',
                               :host     => ''})

account = Account.first
account.is_awesome = true

To quickly test programmatic access with the DataMapper Salesforce adapter, follow these steps:

  • Obtain a working account
  • Get a security token (if you don't already have one)
  • Get the Enterprise WSDL for your object model
  • Copy and modify config/example.rb to use your info
    • The :password field is the concatenation of your login password and the API key
    • If your password is 'skateboards' and API key is 'f938915c9cdc36ff5498881b', then the :password field you pass to DataMapper.setup should be 'skateboardsf938915c9cdc36ff5498881b'
  • Run 'ruby example.rb' and you should have access to the Account and Contact models (schema differences withstanding)

Don't forget:

  • Don't forget to retrieve a new copy of your WSDL anytime you change your Salesforce schema
  • Don't forget to reset/wipe the auto-generated SOAP classes anytime you update your WSDL

Special Thanks to those who helped

  • Yehuda Katz
  • Corey Donohoe
  • Tim Carey-Smith
  • Andy Delcambre
  • Ben Burkert
  • Larry Diehl
  • Jordan Ritter
  • Martin Emde
Jump to Line
Something went wrong with that request. Please try again.