A plugin to connect to Salesforce.com using ActiveRecord-like syntax
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
tasks
test
MIT-LICENSE
README.textile
Rakefile
init.rb
install.rb
salesforce.yml.tpl
uninstall.rb

README.textile

Deprecation notice

SimpleSalesforce is no longer being maintained; you should use the new DatabaseDotCom gem from Heroku instead.

SimpleSalesforce

SimpleSalesforce allows you to interact with Salesforce.com accounts as if they were ActiveRecord databases.

Simply subclass SimpleSalesforce::SalesforceObject::Base with whatever class name you like, choose which Salesforce object type it should represent, and map whichever fields you like to your local object.

On installation, a blank salesforce.yml will be copied into RAILS_ROOT/config – ensure you fill in your username, password and security token.

Installation

script/plugin install git://github.com/survival/simple_salesforce.git

You will also need the RForce (>=0.3) gem, so if you haven’t already in environment.rb:

config.gem 'rforce'

then

rake gems:install

Setting up the model

class SalesforceContact < SimpleSalesforce::SalesforceObject::Base

  use_salesforce_object "Contact"
  map_field :first_name, :to_salesforce_field => :FirstName
  map_field :last_name, :to_salesforce_field => :LastName
  map_field :Salutation    # this is the equivalent of map_field :Salutation, :to_salesforce_field => :Salutation

end

Interacting with the model

SalesforceContact.create(:first_name => "John", :last_name => "Doe")
SalesforceContact.find_by_last_name("Doe")
SalesforceContact.find_all_by_first_name("Jo%")
SalesforceContact.find(:first)

john = SalesforceContact.find(:all, :conditions => {:first_name => "John"})
john.first_name = "Jonathan"
john.save

john.update_attributes(:last_name => "Doer")

john.destroy

Copyright © 2009 Survival International, released under the MIT license